Linux Generate RSA SSH Keys

Posted on in Categories last updated May 27, 2010

How do I generate ssh RSA keys under Linux operating systems?

You need to use the ssh-keygen command as follows to generate RSA keys (open terminal and type the following command):
ssh-keygen -t rsa
OR
ssh-keygen
Sample outputs:

Enter file in which to save the key (/home/vivek/.ssh/id_rsa): 
Created directory '/home/vivek/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/vivek/.ssh/id_rsa.
Your public key has been saved in /home/vivek/.ssh/id_rsa.pub.
The key fingerprint is:
58:3a:80:a5:df:17:b0:af:4f:90:07:c5:3c:01:50:c2 [email protected]

The -t type option specifies the type of key to create. The possible values “rsa” or “dsa” for protocol version 2. The $HOME/.ssh stores the following two files:

  • $HOME/.ssh/id_rsa – Your private RSA key
  • $HOME/.ssh/id_rsa.pub – Your public RSA key

Please do not share keys file with anyone else. You can upload keys to remote server as follows:
ssh-copy-id [email protected]
Finally, you can login to remote server as follows:
ssh [email protected]
scp file.txt [email protected]:~/data2/

See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

1 comment

Leave a Comment