ssh-keygen - how to set an rsa key with a certain username ssh-keygen - how to set an rsa key with a certain username linux linux

ssh-keygen - how to set an rsa key with a certain username


Use the -C option to provide a new comment with your key.


Explanation: In general, the last string in your ssh public key would be a single comment which in default configured to your user@host. You can override this comment by adding -C argument and edit this string.

For example In default behaviour, lets say that - if your linux hostname is Ubuntu and your user name is john.doe while you watch your public key performing cat ~/.ssh/id_rsa.pub you would see something like this:

ssh-rsa <someReallyBigToken>== john.doe@ubuntu

Documentation:

ssh-keygen will by default write keys in an OpenSSH-specific format.This format is preferred as it offers better protection for keys atrest as well as allowing storage of keycomments within the private key file itself. The key comment may be useful to help identify the key. The comment is initialized to``user@host'' when the key is created, butcan be changed using the -c option.

Solution: override this comment and use -C argument for comment.

ssh-keygen -t rsa -b 4096 -C message-in-a-bottlecat ~/.ssh/id_rsa.pub// output:ssh-rsa <someReallyBigToken>== message-in-a-bottle


ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]

I use this command for generating ssh key for generating github, gitlab and GCP.Here is the documentation for creating ssh key with a username.