sftp without password and no keys to be used

November 29, 2010 at 22:42:58
Specs: Solaris
I have to establish a sftp connection to a server where the user name, password and IP address are configurable. I need a way to automate the password so that I do not get the password prompt. The key generation option is not feasible as access to the remote server is restricted.

i have found option like:
spawn sftp -b batchfile user@ipaddress
expect "password:"
send "userpassword\n";

But the code results in following errors
abc.txt[3]: spawn: not found
couldn't read file "password:": no such file or directory
abc.txt[5]: send: not found

Please provide help

See More: sftp without password and no keys to be used

November 30, 2010 at 08:36:22
I have a few suggestions:

1) I don't mean to elaborate on the obvious, but are you sure expect is located in #!/usr/bin/expect? If it's in a different location, this will not be identified as an expect script.

2) If it is a valid expect script, I would consider using a full path to the sftp command

spawn /path/to/sftp ....

3) Try using \r instead of \n

send "userpassword\r"

4) Probably it's optional, terminate the script with:

expect eof

Report •
Related Solutions

Ask Question