Problem
I would like to authenticate users logging into my OpenServer 6.0.0 system from PuTTY terminal emulations using RSA. How can I configure OpenServer 6.0.0 and my PuTTY client to do this?
Solution
The high level steps you need to take to authenticate a user connecting from a PuTTY terminal emulation on a Windows PC using an RSA public/private key are as follows:
1) Either generate an RSA Public/Private key pair or use an existing RSA key pair already installed on your Windows PC
2) Add the Public key to the $HOME/.ssh/authorized_keys file on your OpenServer 6.0.0 system
3) Configure PuTTY on the Windows PC to use the RSA key when connecting to the OpenServer 6.0.0 system
These steps will now be described in more detail.
1) Generating/importing the RSA key pairIf you do not have an RSA key pair already then use a program like PUTTYGEN (part of the PuTTY package) to generate your RSA key pair.
On your Windows PC run PUTTYGEN and:
- Click on Generate - Its recommended that you enter a Key passphrase and confirm it - Click on "Save public key" and save the key to disk - Click on "Save private key" and save the private key to disk
If you already have an RSA key pair generated using PUTTYGEN then continue to Step 2) below.
If you have an RSA key pair from an OpenServer 6.0.0 system you can import it to use with PuTTY as follows:
- Copy the RSA private key (id_rsa) from the OpenServer 6.0.0 system to the Windows PC - Run PUTTYGEN - Click Conversions -> Import Key - If the key has a Passphrase enter it - Click on "Save public key" and save the key to disk - Click on "Save private key" and save the private key to disk
2) Adding the Public key to your OpenServer 6.0.0 system
From your Windows PC, using PuTTY, login to the OpenServer 6.0.0 system as the user you want to configure RSA authentication for.
If the directory $HOME/.ssh does not already exist type:
- mkdir $HOME/.ssh
- chmod 0700 $HOME/.sshCreate a file using your favourite editor in $HOME/.ssh called
authorized_keysand paste the "Public key for pasting into OpenSSH authorised_keys file:" into the this file.
Please Note: Make sure when pasting the public key that it is pasted as a single line of text. If it is not, then RSA authentication will fail.
3) Configuring PuTTY to use the RSA keyOn your Windows PC start PuTTY and in the "PuTTY Configuration" window do the following:
- Enter the Host Name (or IP address) of the OpenServer 6 Server you want to connect to - Make sure the protocol is set to SSH - Under Category -> Connection -> SSH -> Auth click on "Browse" and select the RSA Private key that you generated using PUTTYGEN in step 1) above. - Click on Category -> Session, enter a name for the session in the "Saved Sessions" field and click on "Save". This will save the session so that you do not have to perform the steps above each time you invoke PuTTY - Click on "Open"
You should now have a PuTTY Terminal Emulation with a:
login as:prompt. Enter the username of the user we setup the authorized_keys file for in Step 2) above and, if all has been configured correctly you should see the following prompt
Authenticating with public key "demo-key" Passphrase for key "demo-key":
Enter the passphrase for the key you created in Step 1) above and you will then be logged into the system.