# HG changeset patch # User Mads Kiilerich # Date 1577628909 -3600 # Node ID c8af6594ded95d45432f017a2441951ffcee6d6d # Parent 1eca0ed41a6e3481ffe52119b268b1ac12267d66 ssh: tweak some exception messages to make them more helpful in context diff -r 1eca0ed41a6e -r c8af6594ded9 kallithea/lib/ssh.py --- a/kallithea/lib/ssh.py Sun Dec 29 01:47:29 2019 +0100 +++ b/kallithea/lib/ssh.py Sun Dec 29 15:15:09 2019 +0100 @@ -46,7 +46,7 @@ >>> parse_pub_key('''AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ''') Traceback (most recent call last): ... - SshKeyParseError: Incorrect SSH key - it must have both a key type and a base64 part + SshKeyParseError: Incorrect SSH key - it must have both a key type and a base64 part, like 'ssh-rsa ASRNeaZu4FA...xlJp=' >>> parse_pub_key('''abc AAAAB3NzaC1yc2EAAAALVGhpcyBpcyBmYWtlIQ''') Traceback (most recent call last): ... @@ -74,7 +74,7 @@ parts = ssh_key.split(None, 2) if len(parts) < 2: - raise SshKeyParseError(_("Incorrect SSH key - it must have both a key type and a base64 part")) + raise SshKeyParseError(_("Incorrect SSH key - it must have both a key type and a base64 part, like 'ssh-rsa ASRNeaZu4FA...xlJp='")) keytype, keyvalue, comment = (parts + [''])[:3] if keytype not in ('ssh-rsa', 'ssh-dss', 'ssh-ed25519'): diff -r 1eca0ed41a6e -r c8af6594ded9 kallithea/model/ssh_key.py --- a/kallithea/model/ssh_key.py Sun Dec 29 01:47:29 2019 +0100 +++ b/kallithea/model/ssh_key.py Sun Dec 29 15:15:09 2019 +0100 @@ -126,7 +126,7 @@ elif ssh.SSH_OPTIONS in l and ' ssh-serve ' in l: pass # Kallithea entries are ok to overwrite else: - raise SshKeyModelException("Safety check failed, found %r in %s - please review and remove it" % (l.strip(), authorized_keys)) + raise SshKeyModelException("Safety check failed, found %r line in %s - please remove it if Kallithea should manage the file" % (l.strip(), authorized_keys)) fh, tmp_authorized_keys = tempfile.mkstemp('.authorized_keys', dir=os.path.dirname(authorized_keys)) with os.fdopen(fh, 'w') as f: