How to keep ssh-keygen from using my login and computer name in the public key?

Boon picture Boon · May 27, 2009 · Viewed 14.6k times · Source

I ran ssh-keygen on OS X and when I displayed the public key generated, I saw that my login and machine name appears in the last part of the key. Is there any way to have it use a different value or not use it at all?

Answer

bignose picture bignose · May 27, 2009

From the manpage ‘ssh-keygen(1)’:

For RSA1 keys, there is also a comment field in the key file that is only for 
convenience to the user to help identify the key.  The comment can tell what the 
key is for, or whatever is useful.  The comment is initialized to “user@host” 
when the key is created, but can be changed using the -c option.
…
-C comment
        Provides a new comment.

-c      Requests changing the comment in the private and public key files.  This 
        operation is only supported for RSA1 keys.  The program will prompt for 
        the file containing the private keys, for the passphrase if the key has 
        one, and for the new comment.

So, when creating the key you use -C "$desiredcommenttext" to provide whatever comment text you like; or for an existing key, use the -c option to change the comment.