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
0 comments:
Post a Comment