I just installed ubuntu and would like to set its rsa keys up with bitbucket/github. When I ssh-keygen the keys are generated as they should be
ssh-rsa AA...yBEz3pLL georgemauer@ubuntu
which is perfectly usable except the username part. In every rsa key I've generated previously, the username section read my email address:
ssh-rsa AA...yBEz3pLL [email protected]
No, it's not a major impediment but if I don't get this right it will drive me crazy. How, do I generate with rsa keys with an email username of my choice?
The public key is placed into the home directory of the user on the server who used ssh-keygen and ssh-copy-id to generate it and put it there. If you use ssh to connect to the machine with no username, it will attempt to connect with the username of whoever is logged in.
To set up public key authentication using SSH on a Linux or macOS computer: Log into the computer you'll use to access the remote host, and then use command-line SSH to generate a key pair using the RSA algorithm.
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 at rest as well as allowing storage of key comments 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, but can 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-bottle cat ~/.ssh/id_rsa.pub // output: ssh-rsa <someReallyBigToken>== message-in-a-bottle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With