Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sftp script

Status
Not open for further replies.

nimrodman

MIS
Nov 22, 2005
43
US
Does anyone have a script or can suggest a clean way to do a script for sftp, please, I am trying to solve a delivery issue and the suggestion came up that maybe we should consider using secure ftp, thanks.

Any suggestion would be highly appreciated.
 
Why don't you use this command instead of the sftp:

(make sure you are in the destination dir)

ssh node1 'cd /source_dir; find . -print | backup -iqf -' | restore -xpvqf -

or you can use the scp as well to copy directy from one machine to the other (as long as the ssh is configured between the two machines)

man scp for more info

Regards,
Khalid
 
OpenSSH (which is the one that came on my 'extras' CD) has the -b flag so that you can run
Code:
 sftp -b batchfile user@host
You want to use Public/Private key pairs to avoid login problems. If you have sftp then the man page is pretty good, if not here it is

On the internet no one knows you're a dog

Columb Healy
 
Oh, you want to give a plaintext password in the script, thus bypassing all security? Well... sftp requires a terminal. So, give it one:


#!/usr/bin/expect

set timeout -1

set password [lindex $argv 0 ]
set account [lindex $argv 1 ]
set script [lindex $argv 2 ]

log_file /home/dir/sftp.log

spawn /usr/bin/sftp -C -b $script $account
expect "assword:"
send -- "$password\r"
send -- "\r"
expect eof




Using public key cryptography instead is of course recommended as it is

- safer

- simpler to implement

- not your Fault (plaintext passwords can become)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top