Skip to main content
2 of 2
No need for "touch", the echo command will create the file.
terdon
  • 252.2k
  • 69
  • 480
  • 718

On Debian-based distributions, the sshpass package provides an easier way of doing what you want. The package is available for many other popular distributions. You need to set it up first:

echo 'YourPassword' > passwordFile.txt
chmod 600 passwordFile.txt

Then invoke the SSH command from a script like this:

sshpass -f /path/to/passwordFile.txt /usr/bin/ssh -p 8484 [email protected]

This provides more flexibility, such as if you're using a different locale or need to change the password, than solutions using expect.

likeitlikeit
  • 2.4k
  • 1
  • 15
  • 7