How to generate RSA keys on linux

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
Sample outputs: 

Enter file in which to save the key (/home/tommy/.ssh/id_rsa): 
Created directory '/home/tommy/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/tommy/.ssh/id_rsa.
Your public key has been saved in /home/tommy/.ssh/
The key fingerprint is:
10:5a:10:b5:df:14:b0:af:2f:90:05:c1:3c:04:50:c1 [email protected]


The -t type option specifies the type of key to create. The $HOME/.ssh stores the following two files:

  • $HOME/.ssh/id_rsa – Your private RSA key
  • $HOME/.ssh/ – 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-copy-id [email protected]
scp file.txt [email protected]:~/somefolder

Posted on: Saturday 26 November 2016