Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 952
Boon Avatar asked May 27 '09 04:05

Boon


People also ask

How do I name my ssh-keygen?

You need to name the SSH key in the Choose a name for this key field. The default key name is id_rsa . Using the default name will allow SSH clients to automatically locate the keys so it is strongly recommend you use the default name (simply leave the field blank or fill it with id_rsa ).

Where does ssh-keygen save?

ssh-keygen without a password By default, your private and public keys are saved in your ~/. ssh/id_rsa and ~/. ssh/id_rsa. pub files, respectively.


2 Answers

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.

like image 129
bignose Avatar answered Oct 01 '22 09:10

bignose


Yes! It isn't needed at all, it's just arbitrarily appended to make it easy for you to remember where it came from. If you want to edit it, just open a Terminal session and type:

$ nano ~/.ssh/id_rsa.pub 

Remove the end part of the line (after the double-equals).

like image 35
Aupajo Avatar answered Oct 01 '22 09:10

Aupajo