Yet another sftp automation question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Yet another sftp automation question
# 1  
Old 07-13-2011
Yet another sftp automation question

Hello,

I've read quite a few of the sftp questions and answers on the forum but I believe my situation is slightly different.

I need to automate an sftp transfer to a host that requires not only a ssh publickey, but also a password.

When I try using sftp in batch mode, supplying a "user '<uname>' '<pwd>'" config simply does not work.
sftp -b - user@host <<!
<commands>
!
During verbose output I see the remote host responds:

Quote:
authmethod_lookup publickey
...
Authenticated with Partial success
Authentications that can continue: password
...
authmethod_lookup password
I've tried various things in the batch commands to no avail Smilie

Cheers,
n
# 2  
Old 07-13-2011
You should really go for exchanging keys for passwordless authentication, if this is an option in your environment. That would be the usual way how to do it.

Here are 2 more threads with discussion about this topic:
https://www.unix.com/shell-programmin...-scp-help.html
https://www.unix.com/unix-advanced-ex...assphrase.html
# 3  
Old 07-13-2011
Another option is to use tcl/expect to script the operation.
# 4  
Old 07-13-2011
Quote:
Originally Posted by n3llyb0y
When I try using sftp in batch mode, supplying a "user '<uname>' '<pwd>'" config simply does not work.
It, as well as scp, sudo, su, and other sane authentication systems, are designed to do this. Password authentication means 'password typed by a human authentication' and they only accept a password from anything else under great duress. This is a security feature, because stored plaintext passwords are almost impossible to keep safe.

You might try ssh-agent, which would allow you to type the password in but once and remember the key for later.
# 5  
Old 07-13-2011
MySQL thanks

Thanks people.

I'm trying to get the recipient to drop the password requirement as this looks to be the optimum approach. We're encrypting the actual bits as well as the tunnel so I think we should be good. Failing that an expect script might be the way forward. ssh-agent is not an option in my particular situation.

Didn't know about expect or ssh-agent before today so many, many thanks for your replies Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Question about SFTP command

Hi All, This is JCL that contain command script to copy file to destionation (UNIX) I have 2 questions. ********* //NATTOUT1 JOB ACCL,'XXXXYYYY',CLASS=A,MSGCLASS=X, // NOTIFY=&SYSUID,REGION=0M,USER=SFTPXXX // SET... (1 Reply)
Discussion started by: getandput
1 Replies

2. Shell Programming and Scripting

sftp automation script not working

Hi all , can any one tell me how to code SFTP automation script ? I searched lots of forums but i didn't get any useful information:( I don't want auto Login script > like if u run the script it should automatically login into specific account and etc.. Just i want the following things... (4 Replies)
Discussion started by: sravan008
4 Replies

3. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

4. UNIX and Linux Applications

Question concerning enterprise ftp/sftp solutions

Would any of you have any good experiences, recommendations here. We are basically looking for a one stop solution for ftp/sftp including key and encryption management. FTP/S and any HA functionality would be a great bonus. Cheers! (1 Reply)
Discussion started by: Eronysis
1 Replies

5. Solaris

SFTP log question

On a Sun Solaris 9 box, how do I know what kind of SFTP server is running? And, if someone sftp'ed a file to my box, where is the log file I can check if the sftp session was a successful one or not? (1 Reply)
Discussion started by: fld2007
1 Replies

6. UNIX for Advanced & Expert Users

SFTP automation with password/passphrase

Hi All, We have a special requirement from our client, we need to automate one of the sftp job with password authentication. I know sftp can be automated with Key authentication, but this is not what I am looking for. Can some body help me, a method like .netrc in FTP automation or like sftp... (6 Replies)
Discussion started by: shihabvk
6 Replies

7. Solaris

SFTP file format question

Hi, We here at State of Iowa are trying to SFTP an ascii text file off of an IBM server over to our DOL SUN Server using Solaris 5.8. After doing the secure handshake login all I am doing at present is "sftp> get testfile". Somehow in pulling the file in from the IBM server to the SUN server it... (2 Replies)
Discussion started by: wsiefkas
2 Replies

8. UNIX for Dummies Questions & Answers

Question about Openssh and sftp

I have to create an automated sftp job on an AIX box. The sftp command doesnt work. Do I need to install the openssh package in order to be able to invoke the sftp command? (2 Replies)
Discussion started by: NycUnxer
2 Replies

9. Shell Programming and Scripting

SFTP password automation

I am working on a script to automate and SFTP that I am currently doing to a company that does not allow for a .ssh profile to be created. I have search and read about the -b option and am wondering if i can get some more information about it. I tried to right a file containing the password... (3 Replies)
Discussion started by: jaycheetwood
3 Replies

10. Shell Programming and Scripting

SFTP file transfer mode question

I am having trouble viewing a file in ASCII after doing a 'get' using SFTP. It appears to have come across as machine language. Does the file have to be in ASCII format prior to the 'get' or is there a way to convert it to ascii after I get it onto my server? I have read where the secure file... (0 Replies)
Discussion started by: wsiefkas
0 Replies
Login or Register to Ask a Question