diff --git a/kallithea/model/ssh_key.py b/kallithea/model/ssh_key.py --- a/kallithea/model/ssh_key.py +++ b/kallithea/model/ssh_key.py @@ -45,9 +45,11 @@ class SshKeyModel(object): Will raise SshKeyModelException on errors """ try: - ssh.parse_pub_key(public_key) + keytype, pub, comment = ssh.parse_pub_key(public_key) except ssh.SshKeyParseError as e: raise SshKeyModelException(_('SSH key %r is invalid: %s') % (safe_str(public_key), e.message)) + if not description.strip(): + description = comment.strip() user = User.guess_instance(user) diff --git a/kallithea/tests/functional/test_admin_users.py b/kallithea/tests/functional/test_admin_users.py --- a/kallithea/tests/functional/test_admin_users.py +++ b/kallithea/tests/functional/test_admin_users.py @@ -553,7 +553,7 @@ class TestAdminUsersController(TestContr self.checkSessionFlash(response, 'SSH key %s successfully added' % fingerprint) response.follow() ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() - assert ssh_key.description == description + assert ssh_key.description == u'me@localhost' response = self.app.post(url('edit_user_ssh_keys_delete', id=user_id), {'del_public_key': ssh_key.public_key, diff --git a/kallithea/tests/functional/test_my_account.py b/kallithea/tests/functional/test_my_account.py --- a/kallithea/tests/functional/test_my_account.py +++ b/kallithea/tests/functional/test_my_account.py @@ -285,7 +285,7 @@ class TestMyAccountController(TestContro response.follow() user_id = response.session['authuser']['user_id'] ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one() - assert ssh_key.description == description + assert ssh_key.description == u'me@localhost' response = self.app.post(url('my_account_ssh_keys_delete'), {'del_public_key': ssh_key.public_key,