Use Putty to Connect to a Linux VPS WITH an SSH Key
These instructions are intended for PC users that want to configure Putty to to use an SSH key to authenticate to the Linux VPS, without using the username and password. If you already have Putty configured to use an SSH key then you can skip this process and proceed to the next section to :ref:`disable password logins and root login access<disablepasswordlogins>`.
- :ref:`Download Putty and Connect to a Linux VPS without an SSH Key<puttywithoutsshkey>`
- :ref:`Generate a New SSH Key<pcgeneratesshkey>`
Do not proceed with the following steps until the above prerequisites have been completed successfully.
Configure Putty to use an SSH Key
Follow these steps to add the SSH key into the rupx01 Putty session.
- Open Putty and click on the saved session named rupx01 and click Load
- Expand the SSH Category on the left side of the window
- Click on the Auth Category so that it is highlighted
- Click on Browse on the right, under to the field Private key file for authentication
- Browse to the folder that contains your SSH private key
- Select the sshprivatekey.ppk file and click Open
- Scroll back up on the left under Category and click on the word Session, at the top of the window, to bring back the Saved Sessions page
- Click on Save to save the SSH Key to the rupx01 session.
- NOTE: This step is very important. Make sure that your server rupx01 is loaded in the Saved Sessions window and that you click Save. If this step is not completed successfully, then your SSH Key will not be saved to this session and you will have to repeat these steps again
In the Putty window, click Open to connect to your Linux VPS.
- Click Yes on the PuTTY Security Alert to install the security certificate
- Login as the root user and type in, or paste in, your root password.
- The screen will not display your password
- NOTE: For those using Digital Ocean as your VPS provider, you will be prompted to change your root password.
Configure the Linux VPS to use an SSH Key
You should be logged into the Linux VPS as the root user to complete the following steps:
Change directory into the /root/.ssh directory or create it if necessary:
NOTE: If the directory does not already exist then use this command to create it:
Create and edit the file named authorized_keys with the following command:
Paste the SSH public key into the authorized_keys file on the Linux VPS. This is the public key that you generated and then copied from the PuttyGen application.
- CRITICAL NOTE: The SSH key that you paste in should begin with the text ssh-rsa and should end with a date, such as rsa-key-20181012. If you do not get the entire key pasted into this file then the following steps will fail and you will have to repeat these steps.
Save and close the file by hitting Ctrl-X, and then type Y to confirm that you want to save it, and then hit ENTER to confirm the file name.
- NOTE: Your new SSH key is now saved in the /root/.ssh/authorized_keys file. All future logins with the root username will allow you to login without being prompted for a password.
Let's test it!
Duplicate the current Putty session and login as the root user. This will verify that you can now login to the Linux VPS without entering a password.
- To duplicate the existing Putty session to the Linux VPS, click the icon of two computers on the top left of the Putty application window and then select Duplicate Session
- NOTE: You should be automatically logged in to the Linux VPS without having to type in the root password
If you are not automatically logged in without typing in a password then you likely did not save the SSH key into the putty session correctly, or you did not save the entire SSH key into the Linxu VPS file /root/.ssh/authorized_keys. You will need to walk through the steps to save the SSH key in the Putty session and to ensure that the ENTIRE SSH key is added to the authorized_keys file on the Linux VPS before you proceed with the next section.
If you are able to use Putty to login to the Linux VPS without being prompted for a password then you are done configuring your SSH keys and can proceed to the next section to :ref:`disable password logins and root login access<disablepasswordlogins>`.