Passwordless authentication between two Linux servers

Passwordless authentication between two Linux servers Jenkins & web server

On Jenkins Server
Generate SSH Key:
Generate an SSH key pair. If you don't have an existing key pair, you can create one.

ssh-keygen -t rsa

Copy the Public Key to Web Server:

ssh-copy-id username@webserver_ip

On Web Server:
Add/Enable SSH Configuration:
Verify that your SSH server on the web server allows key-based authentication enabled 

sudo vi /etc/ssh/sshd_config
PubkeyAuthentication yes
PasswordAuthentication yes

Restart ssh service
sudo systemctl restart ssh

Set permission
Make sure the permissions on the .ssh directory and the authorized_keys file are secure:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Testing:
Try to SSH from Jenkins to the web server:

ssh username@webserver_ip



Share on Google Plus

About Md. Shahzad Alam

I am a passionate cloud and DevOps professional specializing in Linux and open-source solutions. Through this blog, I share my knowledge and experience with the community, offering tips and insights on cloud technologies and DevOps practices.
    Blogger Comment

0 comments:

Post a Comment