Jump to content

sftp


Sprouty

Recommended Posts

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

Link to comment
Share on other sites

  • 1 month later...
#!/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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...