In this article we will cover the steps to setup passwordless authentication between servers is a secure way to allow one server to access another without needing to enter a password manually each time. This is typically achieved using SSH key pairs.

Introduction

Passwordless authentication between servers using SSH keys is a secure and convenient way to enable seamless server-to-server communication. This guide will walk you through the steps to establish this authentication method.

Prerequisites

  • 2 Ubuntu servers for master server and Client server
  • servers with Sudo Privileges
  • Create a user on Client server

Steps to Setup Passwordless Authentication between Servers

Please create a user in Client server to setup a passwordless authentication between servers.

Step #1: Create Authentication SSH-Keygen Keys on Master Server

First login into server Master with user and generate a pair of public keys using the following command.

ubuntu@ip-172-31-29-175:~$ ssh-keygen

Step #2: Upload SSH Key to – Client Server

Use SSH from server Master and upload a newly generated public key (id_rsa.pub) on server Client under rushi’s .ssh directory as a file name authorized_keys.

ubuntu@ip-172-31-29-175:~$ ssh-copy-id username@client IP Address
  • Replace username with “Client server” user.
  • Replace Client IP Address with your “Client server IP Address”.

Step #3: Disable Password Authentication (Optional)

For increased security, you can disable password authentication on the remote server and only allow SSH key authentication. To do this, open the SSH server configuration file on the Client server:

ubuntu@ip-172-31-19-219:~$ sudo vi /etc/ssh/sshd_config

Find the line containing PasswordAuthentication and set it to no.

PasswordAuthentication no

Save the file and restart the SSH service.

ubuntu@ip-172-31-19-219:~$ sudo service ssh restart

Step #4: Test SSH Passwordless Login from Master Server

From now onwards you can log into Client Server as a rushi user from server Master as a ubuntu user without a password.

ubuntu@Master IP Address:~$ ssh Clientuser@Client IP Address
  • Replace with Master IP Address with “Master server IP Address“.
  • Replace with Clientuser with “User in Client Server“.
  • Replace with Client IP Address with “Client Server IP Address“.

Successfully, Connected to the Client server.

Now you can access the Client server from the Master server without password Authentication.

Conclusion

Implementing passwordless SSH authentication between servers offers enhanced security, streamlined access, and improved efficiency. By generating and managing SSH key pairs, ensuring server prerequisites, and prioritizing security measures like disabling password-based authentication, administrators can establish a robust and secure method for server-to-server communication. From this we learnt the steps to setup passwordless authentication between servers.

Reference

If you want to learn more about Linux, Please visit official website.

Any queries pls contact @Rushi-InfoTech

Similar Posts

Leave a Reply

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