ssh passwordless
#https://linuxize.com/post/how-to-setup-passwordless-ssh-login/
#Setup SSH Passwordless Login #
#To set up a passwordless SSH login in Linux all you need to do is to generate a public authentication key and append it to the remote hosts ~/.ssh/authorized_keys file.
# Generate a new SSH key pair.
ssh-keygen -t rsa -b 4096 -C "[email protected]"
#on remote vm, set root password
sudo passwd root
#on remote vm, configure ssh to allow root login and restart ssh
nano /etc/ssh/sshd_config
...
service ssh restart
#Copy the public key
ssh-copy-id remote_username@server_ip_address
#If by some reason the ssh-copy-id utility is not available on your local computer you can use the following command to copy the public key:
cat ~/.ssh/id_rsa.pub | ssh remote_username@server_ip_address "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
# comfirm your ssh public key(source machine) is copied and add to authorized_keys(target vm)
ssh remote_username@server_ip_address "cat ~/.ssh/authorized_keys"
#on remote vm, configure ssh to disable root login, disable password login, enable publickey login and restart ssh
nano /etc/ssh/sshd_config
...
service ssh restart
# Login to your remote vm using SSH keys
ssh remote_username@server_ip_address