Operating System - Microsoft
1748266 Members
3151 Online
108760 Solutions
New Discussion

Re: how to provide password in case of batch files(ssh protocol)

 
paolo barila
Valued Contributor

Re: how to provide password in case of batch files(ssh protocol)

so, as Michael Selvesteen said,
I think you should use expect
http://expect.nist.gov
share share share
rmueller58
Valued Contributor

Re: how to provide password in case of batch files(ssh protocol)

Expect is a very nice way to create interaction with the shell for automation


I would use expect to handle the issue.
In the script below I am using scp to scp a file from one server to another.

#!/usr/local/bin/expect
spawn /usr/local/bin/scp -v /tmp/*apphire.txt user@IPADDRESS:/tmp
expect "user@IPADDRESS's password:"
send "password\r"
expect "debug: uninitializing event loop"
send "\r"


For your case

#!/usr/local/bin/expect
spawn ssh root@IPADDRESS
expect "user@IPADDRESS's password:"
send "password\r"
expect "Authentication successful."
send "\r"

Download expect and give it a try,