Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an existing SSH key (public and private), that was created with ssh-keygen. How can I add a comment to this existing key?

share|improve this question

1 Answer 1

up vote 19 down vote accepted

Just add a space after the key and put in the comment, e.g.:

ssh-dss AAAAB3NzaC1kc3MAAACBAN+NX/rmUkRW7Xn7faglC/pxqbVIohbcVOt41VThMYORtMQr
XYt7RzKHjWbHRxf84GIyTlKa8yfNfFlf9oNXdtBXcsJjHIvNsBk= ThisIsAComment

The man page for sshd has a section on the authorized_keys format, where it states that the comment extends to the end of the line. While I haven't tried it, you should be able to put spaces into the comment.

share|improve this answer
I've tried it and we will see if it works. My university requires ssh based login for some things and they said they use the comment (which must contain my username) matching an account to a key. Since I didn't wanted to create another SSH key I simply copied my public key, changed the comment and gave it to them. We will see if it works. – Martin Oct 29 '12 at 13:26 worked. – Martin Oct 29 '12 at 19:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.