diff --git a/_modules/maas.py b/_modules/maas.py
index 8895934..4b127d8 100644
--- a/_modules/maas.py
+++ b/_modules/maas.py
@@ -435,63 +435,64 @@
         return new
 
 
-#class SSHPrefs(MaasObject):
-#    def __init__(self):
-#        super(SSHPrefs, self).__init__()
-#        self._all_elements_url = u'api/2.0/machines/'
-#        self._create_url = u'api/2.0/account/prefs/sshkeys/'
-#        self._config_path = 'region.sshprefs'
-#        self._element_key = 'hostname'
-#        self._update_key = 'system_id'
-#
-#    def fill_data(self, value):
-#        data = {
-#            'key': value,
-#        }
-#        return data
-#
-#    def process(self):
-#        config = __salt__['config.get']('maas')
-#        for part in self._config_path.split('.'):
-#            config = config.get(part, {})
-#        extra = {}
-#        for name, url_call in self._extra_data_urls.iteritems():
-#            key = 'id'
-#            if isinstance(url_call, tuple):
-#                url_call, key = url_call[:]
-#            extra[name] = {v['name']: v[key] for v in
-#                            json.loads(self._maas.get(url_call).read())}
-#        if self._all_elements_url:
-#            all_elements = {}
-#            elements = self._maas.get(self._all_elements_url).read()
-#            res_json = json.loads(elements)
-#            for element in res_json:
-#                if isinstance(element, (str, unicode)):
-#                    all_elements[element] = {}
-#                else:
-#                    all_elements[element[self._element_key]] = element
-#        else:
-#            all_elements = {}
-#        ret = {
-#            'success': [],
-#            'errors': {},
-#            'updated': [],
-#        }
-#        for config_data in config:
-#            try:
-#                data = self.fill_data(config_data, **extra)
-#                self.send(data)
-#                ret['success'].append(name)
-#            except urllib2.HTTPError as e:
-#                etxt = e.read()
-#                LOG.exception('Failed for object %s reason %s', name, etxt)
-#                ret['errors'][name] = str(etxt)
-#            except Exception as e:
-#                LOG.exception('Failed for object %s reason %s', name, e)
-#                ret['errors'][name] = str(e)
-#        if ret['errors']:
-#            raise Exception(ret)
-#        return ret
+class SSHPrefs(MaasObject):
+    def __init__(self):
+        super(SSHPrefs, self).__init__()
+        self._all_elements_url = None
+        self._create_url = u'api/2.0/account/prefs/sshkeys/'
+        self._config_path = 'region.sshprefs'
+        self._element_key = 'hostname'
+        self._update_key = 'system_id'
+
+    def fill_data(self, value):
+        data = {
+            'key': value,
+        }
+        return data
+
+    def process(self):
+        config = __salt__['config.get']('maas')
+        for part in self._config_path.split('.'):
+            config = config.get(part, {})
+        extra = {}
+        for name, url_call in self._extra_data_urls.iteritems():
+            key = 'id'
+            if isinstance(url_call, tuple):
+                url_call, key = url_call[:]
+            extra[name] = {v['name']: v[key] for v in
+                            json.loads(self._maas.get(url_call).read())}
+        if self._all_elements_url:
+            all_elements = {}
+            elements = self._maas.get(self._all_elements_url).read()
+            res_json = json.loads(elements)
+            for element in res_json:
+                if isinstance(element, (str, unicode)):
+                    all_elements[element] = {}
+                else:
+                    all_elements[element[self._element_key]] = element
+        else:
+            all_elements = {}
+        ret = {
+            'success': [],
+            'errors': {},
+            'updated': [],
+        }
+        for config_data in config:
+            name = config_data[:10]
+            try:
+                data = self.fill_data(config_data, **extra)
+                self.send(data)
+                ret['success'].append(name)
+            except urllib2.HTTPError as e:
+                etxt = e.read()
+                LOG.exception('Failed for object %s reason %s', name, etxt)
+                ret['errors'][name] = str(etxt)
+            except Exception as e:
+                LOG.exception('Failed for object %s reason %s', name, e)
+                ret['errors'][name] = str(e)
+        if ret['errors']:
+            raise Exception(ret)
+        return ret
 
 class Domain(MaasObject):
     def __init__(self):
@@ -586,3 +587,6 @@
 
 def process_domain():
     return Domain().process()
+
+def process_sshprefs():
+    return SSHPrefs().process()
