Feed in your ssh password into Linux SSH command to login automatically
I needed to login to a linux server automatically, but without using Shared RSA Key. I needed to simulate a human being typing password, but to do that automatically so I can use it inside my shell scripts.Surprisingly this solution was difficult to find on Google. I would like to share this simple technique in hope this will save somebody long research time.
This is an alternative solution from login into SSH using Shared RSA Key technique which is much more secure and the recommended method.
WARNING: This method exposes your ssh login / password! (use with caution)
Install sshpass if you don't have it yet:
apt-get update
apt-get install sshpass
Example shell script:
#!/bin/bash
sshpassword=mypassword
sshpass -p $sshpassword ssh 192.168.1.1 "ls -l"