Configure “No Password SSH Keys Authentication” with PuTTY on Linux Servers

SSH (Secure SHELL) is one of the most used network protocol to connect and login to remote Linux servers, due to its increased security provided by its cryptographic secure channel established for data flow over insecure networks and its Public Key Authentication.

While using passwords to login to remote servers can provide a less secure to system security, because a password can be brute-force cracked, SSH Public Key Authentication provides the best secure method to perform distance logins, because it’s almost impossible to decipher the key and the private key guarantees that the sender it’s always who it claims to be.

Putty SSH Passwordless Login

Putty SSH Passwordless Login

This article will show you how you can generate and use SSH Keys from Windows based platforms using Putty client to automatically perform remote logins on Linux servers without the need to enter passwords.

Step 1: Install Putty and Generate SSH Key Pairs

1. The first step you need to take is to go to official Putty download page, grab the last version of the Putty Windows Installer executable package and install it onto your Windows computer.

Download Putty

Download Putty

2. After you have finished installing Putty go to Windows Start, type putty string to search field and open PuTTygen program which you will use it to generate Keys pairs.

Open Putty

Open Putty

3. Once the program opened, its time to proceed with Keys generation. Select SSH-2 RSA Key with 2048 bits, hit the Generate button and move the cursor randomly on Putty Key Generator field window as presented in the screenshots below in order to produce SSH Keys.

Generate SSH RSA Key

Generate SSH RSA Key

Generating SSH Key on Putty

Generating SSH Key

4. After the Keys are generated, add a descriptive Key comment to help you easily identify your key and Save both keys (Public and Private Keys) to a secure location in your computer.

Pay extra attention to where you save the Private Key, because if anyone steals this key it can perform logins to your
server without the need to enter a password.

Also, to enforce Keys security you can choose a passphrase to protect your keys, but you might want to avoid password for automated processes, because it will ask you to enter the password key every time you perform server login.

Add Key Comment in Putty

Add Key Comment

Save SSH Public Key

Save SSH Public Key

Save SSH Private Key

Save SSH Private Key

Location of SSH Private Key

Location of SSH Private Key

5. After you have saved both Keys, don’t close the Putty Key Generator window yet, select copy and save the text field of Public Key into a text file which will be later pasted into OpenSSH authorized_keys file on remote server.

Copy SSH Public Key

Copy SSH Public Key

Location of SSH Keys

Location of SSH Keys

Step 2: Save The Public Key to Remote Server and Login using SSH Keys

6. Now it’s time to copy the key to the destination remote server and perform automatic login connections. Login to server with your administrative user (root or an account with root powers) using Putty and create .ssh directory and authorized_keys file onto its home path by issuing the following commands.

# pwd   		## To see if you are in the correct $HOME location
# mkdir .ssh
# nano .ssh/authorized_keys
Create SSH Directory

Create SSH Directory

7. On the authorized_keys file opened for editing in Putty, paste the content from the Public Key that you copied earlier from Putty Key Generator, save and close the file, protect the folder and authorized_keys with 700 permissions and exit from server.

# chmod -R 700 .ssh/
# exit
Copy SSH Key to Server

Copy SSH Key to Server

Set Permission on Key

Set Permission on Key

8. In order to automatically connect and login to your server you need to add the Private Key to Putty client. Open Putty and add your server login user followed by your server IP Address or FQDN on Host Name field in the form of [email protected], enter your server SSH Port number if it was changed.

Then go to left Category menu, select SSH –> Auth, hit the Browse button, search and add your Private Key.

Connect SSH using Putty

Connect SSH using Putty

9. After you added the Private Key, go back to Session menu, enter a descriptive name to Saved Session field and hit the Save button to save your current Putty session.

Putty Configuration

Putty Configuration

10. That’s it! Now you can automatically securely connect to your remote SSH server with Putty client by hitting the Open button without the need to enter passwords.

Automatically Connect SSH

Automatically Connect SSH

Read Also: SSH Passwordless Login Using SSH Keygen

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

16 Responses

  1. helwi says:

    Dear Mr,

    I have problem with port ssh, I can`t change the default port to custom port. I use 9899 for my custom port. Can you advice me step by step, because I follow your tutorial step by step to change port on sshd_config and also enabled port in selinux but its still not work.

    When I try to connect using the port from other computer in the same network the error connection refused for port 22. When I try add comment -p 9899 in the end command are still refused.

    Can you advice me?

    Tthanks in advanced.
    regard

  2. Matei Cezar says:

    Remove the public key from authorized_keys and the private key from Putty configuration.

  3. andy says:

    how do i revoke this so i can go back to manually inputting passwd

    thanks

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.