Passwordless SSH Login

The meaning of SSH is Secure Shell or Secure Socket Shell. It is a cryptographic network protocol that mainly provides a secure way to connect a remote server in an unsecured network such as the internet. There are various authentication mechanisms to connect the remote server using SSH login. The two most popular mechanisms are password-based authentication and another is password-less key-based authentication.

In this article, you will learn how to set up an SSH-key based authentication and connect to the Linux server without entering a password.

Environment Details

We will be taking two Linux servers having Ubuntu Linux installed on both of them. IPs of both of the systems are given below.

SSH Client :
SSH Remote Host :

In this example, we will set up an SSH passwordless connection from the SSH Client using user tutorialsbook to the SSH Remote Host with user priyam.

Passwordless SSH Login

The following steps describe the process of setting up an SSH passwordless connection in a Linux server.

1) Create Authentication SSH-key on SSH Client (

In the very first step, log in to the SSH Client using the user-id tutorialsbook and generate a pair of keys using the following commands.

ssh-keygen -t rsa

2) Create .ssh Directory on SSH Remote Host (

Using password-based SSH, connect to the SSH Remote Host using priyam as a user and create a .ssh directory under it. You can use the following command.

ssh priyam@ mkdir -p .ssh

3) Upload Generated Public Key to

Now, again using the password-based SSH connection from the Client sends the newly created public key ( to the server under priyam‘s .ssh directory as a file name authorized_keys.

cat .ssh/ | ssh priyam@ 'cat >> .ssh/authorized_keys'

4) Set permissions on

There may be different versions of SSH available on different servers. So it is better to set the correct permission on the SSH Remote Host we need to set permissions on .ssh directory and authorized_keys file as below.

ssh sheena@ "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

5) Login from to Server without Password

All done. From now onwards, you can log in to the server using the user priyam from the client as tutorialsbook user without a password.


Please Share