How to automate SSH login with password?
I'm configuring my test VM, so heavy security is not considered. SSH chosen for acceptable security with minimal configuration.
ex)
echo password | ssh id@server
This doesn't work.
I remember I did this with some tricks somebody guided me, but I can't remember now the trick I used…
Best Answer
Don't use a password. Generate a passphrase-less SSH key and push it to your VM.
If you already have an SSH key, you can skip this step… Just hit Enter for the key and both passphrases:
Copy your keys to the target server:
Now try logging into the machine, with
ssh 'id@server'
, and check-in:to make sure we haven’t added extra keys that you weren’t expecting.
Finally, check to log in…
You may also want to look into using
ssh-agent
if you want to try keeping your keys protected with a passphrase.