Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Configure _No Password SSH Keys Authentication_ with PuTTY on Linux Servers
SSH (Secure Shell) is a popular protocol for securely connecting to remote servers over a network. When you use SSH to connect to a server, you typically need to provide a username and password to authenticate your identity. However, this process can be tedious if you need to connect to multiple servers frequently. Fortunately, there is a solution: No Password SSH Keys Authentication.
In this article, we'll walk you through the process of setting up No Password SSH Keys Authentication on a Linux server using PuTTY, a popular SSH client for Windows. With this setup, you can connect to your servers quickly and securely without needing to type in a password every time.
Prerequisites
Before we begin, make sure you have the following
A Linux server to which you want to connect using SSH.
PuTTY installed on your Windows machine. You can download PuTTY from the official website.
Basic knowledge of Linux commands and how to use the command line.
Why Use No Password SSH Keys Authentication?
There are several benefits to using No Password SSH Keys Authentication
Improved security SSH keys provide a more secure way to authenticate than passwords, as they are much more difficult to guess or crack.
Convenience With SSH keys, you don't need to remember or enter a password every time you connect to a server.
Automation SSH keys can be used to automate tasks on remote servers, such as running scripts or executing commands.
How SSH Key Authentication Works
Generating SSH Keys with PuTTYgen
To use No Password SSH Keys Authentication, you'll need to generate a public/private key pair. PuTTYgen is a tool used to generate and manage SSH keys with PuTTY.
Follow these steps to generate an SSH key with PuTTYgen
Download and install PuTTY from the official website.
Open PuTTYgen by searching for it in the Start menu.
Click the
Generatebutton to create a new key pair. Move your mouse around the blank area to generate random data for the key.Set a passphrase for your private key. This passphrase will be required to use the private key, so make sure to remember it.
Click the
Save private keybutton to save your private key. Choose a secure location to save the file.Copy the contents of the Public key for pasting into OpenSSH authorized_keys file field to your clipboard. This is your public key.
Adding the Public Key to the Server
Now that you have generated your SSH key pair, you'll need to add the public key to the authorized_keys file on the Linux server you want to connect to. Follow these steps
Log in to the Linux server using your password.
-
Create a
.sshdirectory in your home directory if it doesn't already existmkdir -p ~/.ssh
-
Open the
authorized_keysfile in a text editornano ~/.ssh/authorized_keys
Paste the contents of the public key you copied earlier into the
authorized_keysfile.Save and close the file by pressing
Ctrl+X, thenY, thenEnter.-
Set the correct permissions for the
.sshdirectory andauthorized_keysfilechmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
Configure PuTTY to Use Private Key
The final step is to configure PuTTY to use your private key when connecting to the Linux server. Here's how to do it
Open PuTTY, and go to the
Sessioncategory.Enter the hostname or IP address of the Linux server in the Host Name (or IP address) field.
Under the
Connectioncategory, expand theSSHsubcategory, and click onAuth.Click the
Browsebutton next to the Private key file for authentication field, and select the private key file that you saved earlier.Click the
Openbutton to start the SSH session.
You should now be able to connect to the Linux server without needing to enter a password. PuTTY will automatically use the private key for authentication.
SSH Agent Forwarding with PuTTY
SSH agent forwarding is a useful feature that allows you to use your SSH keys on a remote server. This is useful if you need to connect to multiple servers using the same key, or if you need to perform multiple SSH hops to reach a remote server.
To enable SSH agent forwarding
-
Enable SSH agent forwarding on the remote server by adding the following line to the SSH configuration file (
/etc/ssh/sshd_config)AllowAgentForwarding yes
-
Restart the SSH service on the remote server
sudo systemctl restart sshd
In PuTTY, go to
Connection?SSH?Authand check Allow agent forwarding.
Troubleshooting
If you are unable to connect to the Linux server using your private key, try the following troubleshooting steps
| Issue | Solution |
|---|---|
| Connection refused | Verify the public key is correctly added to ~/.ssh/authorized_keys
|
| Permission denied | Check permissions: chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys
|
| Key not recognized | Ensure the private key file is in PuTTY format (.ppk) and correctly selected |
| Still prompts for password | Verify SSH key authentication is enabled in /etc/ssh/sshd_config
|
Conclusion
No Password SSH Keys Authentication is a convenient and secure way to connect to Linux servers without repeatedly entering passwords. By generating SSH key pairs with PuTTYgen and configuring them properly on both client and server, you can streamline your remote access workflow while maintaining strong security. The key-based authentication method is not only more secure than passwords but also enables automation and simplified server management.
