![]() ![]() Then save ctrl + o, ENTER and exit nano ctrl + x. Open the sshd_config file: sudo nano /etc/ssh/sshd_configĬhange PasswordAuthentication yes to PasswordAuthentication no. Now that you have key-based authentication working, you should disable password authentication for SSH to stop brute-force attacks, but note: You must repeat this entire guide for root user, otherwise you will not be able to login as root! Once you have key-based authentication working for root user and your sudo user, you can safely disable password authentication for SSH. Once you have successfully logged in (and saved your private key), you need to delete the private key from your server as it’s a security risk (replace username with your username): sudo rm -rf /home/username/.ssh/id_rsa Disable Password Authentication You should see the Ubuntu Welcome message along with some server statistics: Ubuntu will ask you your username first, then the passphrase you used when you created the key-pair: If you want to save this session so that you don’t have to repeat this process, click the Session heading, then enter a name inside the Saved Sessions field, then click Save:įinally, click the Open button bottom-right to begin the SSH session. On the left-side menu, select Connection -> SSH -> Auth, then click the Browse button under the Private keys for authentication heading, and select your id_rsa.ppk file: Open PuTTY and enter the IP address/hostname of your server into the Host name or IP address field. Now it’s time to test your new key-pair and make sure you can login to your server. PuTTYgen will ask you to enter the passphrase you used when you created the key-pair, so go ahead and enter it.Ĭlick Save private key, name your file id_rsa.ppk and choose a secure location to save it. txt file on your PC and name it id_rsa.txt, save it in a secure place, then paste the RSA key into it.Ĭlick the search icon on your taskbar and search for “puttygen”, then click the PuTTYgen app icon:Ĭlick Conversions -> Import Key from the top menu and choose your id_rsa.txt file. Use the following command to display your private key on the screen, then highlight (PuTTY automatically copies to clipboard when you highlight text): cat ~/.ssh/id_rsaĬreate a new. Let’s copy/download the private key so we can convert to a PuTTY. Let’s copy the public key to authorized_keys: cp id_rsa.pub. You should see three files: authorized_keys where public keys are stored and authorized for use, the private key file id_rsa, and the public key id_rsa.pub: dir Use the dir command to see the contents of the current hidden folder. Let’s change directories to your users home directory (replace username with your username): cd /home/username/.ssh Authorized Keysīefore we can begin using our RSA keys for authentication, we need to copy the public key to authorized_keys. You should now receive an on-screen confirmation that your key-pair has been created and saved in your users home directory.
0 Comments
Leave a Reply. |