The conventional method of logging into an SSH server involves entering a password, which can be cumbersome and, in some cases, less secure. In this article, we’ll explore the process of SSH Login Without Password on Linux, providing a streamlined and secure alternative.
In this article, we will set up passwordless SSH login to a Linux server from a Windows client machine.
Understanding the Conventional SSH Login Process
When connecting to an SSH server, users are typically prompted to enter their username and password. While this method is secure, it requires user intervention, making it less convenient, especially for automated processes or frequent connections.
The Convenience and Security of Passwordless SSH Login
Passwordless SSH login offers a solution to the inconveniences associated with traditional authentication methods. By utilizing public key authentication, users can establish a secure connection without the need to enter a password manually. This method not only enhances convenience but also strengthens security by eliminating the risk of password-related vulnerabilities.
Step-by-Step Guide to SSH Login Without Password on Linux
The first step in achieving SSH login without a password is generating a key pair.
Usually, SSH key pairs are generated on the client machine. However, in our case, we will generate them on the server side and then download them.
This is done using the
ssh-keygen command. To generate private and public files in the .ssh folder, you can use the following commands in the terminal:
ssh-keygen -t rsa
This will create a private key file named “id_rsa” and a public key file named “id_rsa.pub” in the .ssh folder.
Add Public Key to the authorized_keys file
Now you need manually copy the public key to the
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
DO NOT FORGET DOWNLOAD KEY FILES!
Remember to download both the private and public SSH key files from the server and store them in a secure location. Once downloaded, you can safely delete the private key file named “id_rsa” and its corresponding public key file named “id_rsa.pub” from the server. These files are located in the .ssh folder on the server.
Configuring the Server
Before you can achieve passwordless SSH access, you need to configure your server to accept key-based authentication.
Check SSH Configuration:
- Open the SSH configuration file on your server. Typically, this file is located at
/etc/ssh/sshd_config. Ensure the following settings are in place:
PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys PasswordAuthentication no
Reload SSH Service:
- After making changes, reload the SSH service to apply the new configuration:
systemctl reload sshd
Testing the Configuration
To confirm that SSH login without a password is working, attempt to log in from the client machine using SSH client (PuTTY). If you planning using private key in PuTTY you need convert to special PuTTY key format – .ppk.
You should be able to SSH into Linux without being prompted for a password.