You have two hosts that you want to set up password-less access between local to remote system. This can be easily scripted and all commands are run from local system using ssh into remote system starting with password but at the end of these commands you will have password-less authentication set up. Tasks on Source System: (Note that For ESXi 5.x, 6.0, 6.5 and 6.7, the authorized_keys is located at: /etc/ssh/keys-<username>/authorized_keys) ssh-keygen -t rsa ssh remoteuser@remotehost mkdir -p .ssh cat .ssh/id_rsa.pub | ssh remoteuser@remotehost 'cat >> .ssh/authorized_keys' ssh remoteuser@remotehost "chmod 700 .ssh; chmod 640 .ssh/authorized_keys" ssh remoteuser@remotehost For two ASW instances we could do following. Call the two systems control and managed, where control machine is your source and managed is remote or target. Log into Control machine and perform following. ssh -i "PRIVATE-KEY.pem" ec2-user@ec2-1-2-3-4.e...
Inspired by infrastructure as code...