You are not logged in.

#1 2008-02-22 15:13:34

Thrillhouse
Member
From: Arlington, VA, USA
Registered: 2007-05-29
Posts: 175

sftp batch job with password?

Hi folks.

We're trying to develop scripts to automate the transfer of files from various Windows machines to a Linux server.  Because the job involves moving multiple files to multiple directories, I wanted to use sftp's -B batchfile option to transfer the files instead of having to reauthenticate every time we transfer files to a different location.  However, the man page says:

Batch mode. Reads commands from a file instead of standard input. Since this mode is intended for scripts, SFTP2 will not try to interact with the user, which means that only passwordless authentication methods will work.

I would love to use keys to get this done but unfortunately, the type of authentication on the server is out of our control and not likely to change (it's straight password).  So, is there any way I can do this in batch mode with password authentication?  I thought about using scp but, as far as I can tell, it doesn't have great support for delivering multiple local files (in different locations) to multiple remote locations.  One would have to re-authenticate for every scp command, right?

Any help would be appreciated.  Thanks.


For the strength of the pack is the wolf, and the strength of the wolf is the pack.

Offline

#2 2008-02-22 19:25:51

Endperform
Member
From: Atlanta GA, USA
Registered: 2007-09-04
Posts: 94
Website

Re: sftp batch job with password?

I'm assuming you're trying to set this up on the Windows side.  You might try Expect:

http://expect.nist.gov/

With Expect, you can script what you need to.  I'm no expert, but I know this should do what you're looking for.

Offline

#3 2008-02-28 19:44:30

Thrillhouse
Member
From: Arlington, VA, USA
Registered: 2007-05-29
Posts: 175

Re: sftp batch job with password?

Thanks for the recommendation, Endperform, but after reading up on expect and autoexpect, I realized I'd rather not have usernames and passwords hard coded into the script.

After much research, I think I've found a solution.  It's a little odd but the Maverick Ant library does exactly what I need it to do.  It can actually read an ssh profile, perform multiple transfers without having to re-authenticate and execute multiple remote commands without having to reauthenticate.  The native Ant libraries can't do this.  There is no sftp Ant task and the scp and sshexec tasks are lacking to say the least.

If anyone else runs into a similar situation, I highly recommend the Maverick tool.


For the strength of the pack is the wolf, and the strength of the wolf is the pack.

Offline

Board footer

Powered by FluxBB