Linux includes SSH support, so you don't need to download any special programs to generate SSH keys.
To create and configure SSH keys, it's simple and fast on Linux.
Open your terminal to enter the command:
ssh-keygen -t rsa
Press Enter when you are asked where to save the key.
Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'. Enter passphrase (empty for no passphrase):
Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is: SHA256:DFUlBvAL2up2KPk/LvFSfPcqJGu0E6XEsFSIBvn3WJQ root@b73555644e6a The key's randomart image is: +---[RSA 2048]----+ |.o . ooooo+.. | |. o + Eo . . | | o . =o . | | . oo++.. | | ..*.oS | | o.O o . | | ..* B . . | | o.= O . . | | +oBoo ... | +----[SHA256]-----+
You can optionally add a passphrase to the key. If you are generating keys to use in automated processes, you should just press Enter.
However, if you want to set up two-factor authentication by using key files and a password, then type a password for the key and then press Enter.
At the command line, type the following command:
root@b73555644e6a:/# cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChVM91KLyt244eP8eZyXw0030nes0ZBbsqK+F4EtcZGt2q2v1syvMSe8T9yzUaQrAeN+KT+Poxye8sqXFl5PfgzgjAWUewW/Z5kJxCo6Qv5qF6lanMBwBEudPpkCmcezqEFrui4odAndSE2Uro4PQp2CEjbQvgOPZV66dUMSS5ZCnWi3HL1R0ImCv4MKFwwIrmmKTqnBVAI2IC9ljbVBDx5+bneC3G1DlLAYdQcrg8Q04g17KyKsGGi00nbgGNI8KVdnIyC1JUx7deIT2xn53EzwXWCXuZukK1Xn+0t9Qu+wuqFPf7hSCpFDhljTR5duAJsKr22TkU/JV1JCoIfr5f root@b73555644e6a root@b73555644e6a:/#
Select the text in the file and copy it.
Log in to your account using SSH. At the command line, type the following command, replacing username wih your username, and example.com with your site's domain name:
At the command line, type the following commands:
In the VIM text editor, paste the public key text.
If you are setting up multiple key pairs, the authorized_keys file may already contain data for other key pairs. If this is the case, then just append the new public key text to the file; do not delete the existing key information.
Press Ctrl+x, type y to save the file, and then press Enter. Save the file and exits.
Hit the Esc key to enter "Normal mode". Then you can type
: to enter "Command-line mode".
A colon (
:) will appear at the bottom of the screen and you can type in one of the following commands. To execute a command, press the Enter key.
At the command line, type the following commands to set the correct file permissions:
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
To close the connection, type exit and then press Enter.
At this point, you have created the SSH key pair and deployed the client's public key to the server. You are now ready to connect to your SSH account using the keys.