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)
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.eu-west-1.compute.amazonaws.com
- ssh-keygen -t rsa
- cat .ssh/id_rsa.pub
- Take a secure copy of above output which is the key.
- Now log into Managed machine and perform following
- mkdir -p .ssh
- vi .ssh/authorized_keys # Create/ Edit this file
- Paste the output of secure copy of key you obtained from control machine into this file.
- chmod 700 .ssh
- chmod 640 .ssh/authorized_keys
- Now you should be able to ssh managed machine from control machine without any key or password.