This article is an advance version of DreamHost SSH article. If you are using the SSH for login to the server then this article will be helpful to you. Every time, you connect to the server using SSH, you will have to give the password for login. There is no way to save the password. However, you can login to the server using RSA keys.
In this article, I will show you how to generate RSA keys and where to save them so that you can login without password.
Use of RSA keys in PuTTY On Windows System
Whether you are using Windows system or Linux system, you will have to first generate RSA keys. In Windows system, you can generate RSA keys using PuTTYgen application. First download the PuTTYgen application from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html .
Click on Generate button. Now you will have to move your mouse in the blank are of key under the processbar. Otherwise the keys won’t be generated.
You can now see the public key.
You will need to copy this public key to the authorized_keys file on the server. Authorized_keys file is located under .ssh folder under your home directory. If the file is not there then create the new with the “authorized_keys” name. Please remember you will have to directly copy the public key from the key box area to the server.
If you want to first save the public key and private key to the files then you will have to modify the content of public key before putting it on the authorized_keys file.
The content of the public key on the file looks like below.
---- BEGIN SSH2 PUBLIC KEY ---- Comment: "rsa-key-20170226" AAAAB3NzaC1yc2EAAAABJQAAAQEAk5H84pUwA23AfZjoSEDmZr649rkawjkL+UMhGjdeN8NTwZC9Zzi5bmsMCmu8+KWEZORme35+mEDLKa15uehsSEEz+t7DGIKfxIl7jWjwQpBJj+EIIHUS/K0ZzUAf3fp3UhvihE4tLQr/yCPzFMtHSutt8gAA7zSi7h8r82SBnvHKnjWCc+kIkKEv9NdSC5lalCplySkbVeIZwU2odYRW20XdjVtJl8w0+DVdSXYC9798cg0dmsN007F04+FlozK09kbQrZKqOeLJYbSK0GM2R3oJq6BSrG632PE3fbrbncr1TNeDHxdg4pNheo6a6+DAuRs6Y4+/KY9Hq4ZPiT1Iqw== ---- END SSH2 PUBLIC KEY ----
You will have to modify it like the following before putting it on authorized_keys file.
Please remember to keep only single line for a single key. If the key is break in more than one line then it won’t work. Now put it on the authorized_keys file on the server.
Now you will have to set the private key to the PuTTY.
Open PuTTY. Click on the Plus sign beside SSH. Then click on Auth. Click on Browse button and select the private key file.
Click on Open. You will be asked for the username. Enter username. If no passphrase is set then you will be logged in to the server.
Use of RSA keys in Linux System
Since you are using Linux, you are a bit technical person. In Linux, it is easy to setup RSA keys for SSH authentication.
You will need to generate RSA keys on your local system. Generate RSA keys using following command.
#ssh-keygen -t rsa
You can enter passphrase if you want to keep it otherwise leave it blank and press enter key to keep it empty. Now you can login without password.
Next thing is you need to copy the id_rsa.pub file to authorized_keys file at DreamHost server. Use following command for that.
#scp .[email protected]:~/.ssh/authorized_keys
That’s it. You can now use SSH command on your Linux system and try to connect to the DreamHost server. If no passphrase is given then you will be logged in otherwise you will have to enter the passphrase.
I hope you will enjoy RSA keys authentication.