Home SSH - Passwordless login
Post
Cancel

SSH - Passwordless login

It would be best if you dedicated an account on the servers being managed, so create the same account on each server.

Now lets get SSH passwordless login working for this account. You may need to “rm -rf .ssh” on both the local and remote servers.

1
sudo -i -u user-account

Generate and copy the SSH keys from the “master” server to each remote server.

1
2
ssh-keygen
ssh-copy-id user-account@server-name

Lets assume that the remote computers as a plain Ubuntu 22 install. Edit the SSH config file to allow root login. You will need to SSH into each remote box and run the following two commands.

1
sudo systemctl restart ssh

Now SSH into each remote server as root and accept the “authenticity of host” prompt for each remote. Now SSH into each remote server as root again and confirm that no password prompt is displayed.

Now set the user-account one each server-name to not ask for a sudo password:

1
sudo visudo

At the bottom of the file add:

1
user-account    ALL=(ALL) NOPASSWD:ALL
This post is licensed under CC BY 4.0 by the author.