0

So I am running Linux Mint 17.2. I have a bash file I would like to run in terminal to login via SSH into my other mint 17.2 server. I am able to do this manually no problem, but when I try using the following script, it attempts to connect to the server, but then it just sits there at the password prompt.

#!/bin/bash
ssh mediaserver@mediaserver
expect "pasword:"
send "password\r"

not sure what to do here. Online help gets me no where so far.

amc
  • 7,142

1 Answers1

1

There is a package called sshpass that does what you want.

sudo apt-get install sshpass

Once it's installed, you can put into your script the following:

sshpass -p 'password-here' ssh mediaserver@mediaserver

Of course, it's generally not good practice to put a plain text password into a script or into source code. That said, this does exactly what you are asking.