Sprouty Posted August 12, 2009 Share Posted August 12, 2009 Hi, I'm trying to upload some files to a sftp server, and keep having problem when connection due to the promt with password. so far i have got this #!/usr/bin/expect spawn sftp -b /home/user/sendfiles.txt username@ipaddress <<-EOF expect "password:" send "passwrod\n"; interact but come back with this error messageermission denied (publickey,gssapi-with-mic,password). anyone got a quick fix or different method? this is currently running on ubuntu server. cheers, sprouty Quote Link to comment Share on other sites More sharing options...
Burncycle Posted August 12, 2009 Share Posted August 12, 2009 Have you thought of using key based authentication? http://www.linux.com/archive/feature/34958 Quote Link to comment Share on other sites More sharing options...
Sprouty Posted August 12, 2009 Author Share Posted August 12, 2009 hi Burncycle, That for the quick reply. Yer i have though about this, but unfortutantly i don't have control of the remote server, and they wouln't allow me :-(. so was after a quick work around, with no luck atm :-( Many Thanks Sprouty Quote Link to comment Share on other sites More sharing options...
Hagis Posted October 7, 2009 Share Posted October 7, 2009 #!/usr/bin/expect spawn sftp -b /home/user/sendfiles.txt username@ipaddress <<-EOF expect "password:" send "passwrod\n"; interact the ; in the send is your issue. try something like this.. #!/usr/bin/expect -f set username [lrange $argv 0 0] set password [lrange $argv 1 1] set ipaddr [lrange $argv 2 2] set batchfile [lrange $argv 3 3] spawn sftp -b $batchfile $username@ipaddress expect "*?assword:*" send -- "$password\r" expect eof so to run it it would be something like this >script.exp username password ipaddress /location/batchfile.txt move the EOF to the end and remove the interact, you only need the interact if you plan on interacting with the connection after the script is done. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.