Ask Leo! by Leo A. Notenboom

How can I automate an SFTP transfer between two servers?

Search First! Then browse: Categories | Full Archive | By Date | Newsletter

Home » General Computing

Comments

Read the article that everyone's commenting on.
RSS feed Subscribe to the RSS Feed for comments on this article.

Comment Page:  1  |  2  |  3  |  4  |  5 

Hi!! I'm doing all the steps, but the sftp always asks me for the password. I don't know what is happning, do you?

Please, help!

An

Posted by: An at July 4, 2006 12:45 PM

your public/private keys are probably not compatible with the ssh server. you are probably using either OpenSSH or Putty and your server is probably using an ssh.com based package. If this is the case drop putty and use openssh, create the public and private keys then run ssh-keygen -e -f key.pub > key2.pub (where key is the name of your key) this creates a new copy of the public key which can be used on an ssh.com server. Rename the key2.pub file to key.pub (which probably means you will have to delete existing key.pub) then use the private key (which has not changed) with the new public key (ie upload the new public key). Also don't forget to change the authorisation file on the server (/home/username/.ssh or .ssh2) to accept your new key.

Posted by: Joe at July 19, 2006 12:58 AM

This article is incredible Leo. Thank You.

I have seen the sftp usage options given below,
sftp [-1vC] [-A Password] [-b batchfile] [-L logfilename] [-osshopt=value] [user@]host[:file [file]]

But in my SunOS 5.9 , I am not getting the options -L, -b, -A. What could be the reason. I wanted to get a file transferred from the remote server to my server after I connect through my automated connection script. My automation script connects and gives me the SFTP prompt. It's not identifying the commends given in the batch file.

Thanking you once again for all the help.

Posted by: Manoj Das at September 23, 2006 4:12 AM

There are slightly different versions of sftp on different OS's. Does "man" work on your system? If so I'd try a "man sftp" and see if the documentation includes the features you need.

Posted by: Leo Notenboom at September 23, 2006 8:46 AM

Thank you Leo.

I have checked the man pages for sftp. As you have mentioned -L, -b, -A keys are not available.

I just wanted to connect automatically to a remote system and fetch a file from that machine.
Please see the script I am having.

sftp ncc_b2b@blrsun27
get file1.txt
exit

I have follwed the steps given by you for automated connection. Once I am executing this, it's automatically connecting to the remote system and I am getting the SFTP prompt. But it's not executing the get command.

Can you please guide me how to do this now, as the -b option is not available. Should I go for SSLFTP or any other alternative to this.

Thanking You Leo.

Manoj.

Posted by: Manoj Das at October 3, 2006 7:36 AM

YOu might need to have

get file1.txt
exit

in one file (commands.txt) and then use that as input for the sftp command:

sftp < commands.txt

Posted by: Leo Notenboom at October 4, 2006 3:39 PM

Thank You Leo.

It's working fine now. I have managed to Automatically connect to the remote machine and transfer the required file. All because of your help.

Once Again Thanking You Leo,
Manoj.

Posted by: Manoj Das at October 4, 2006 11:47 PM

Hi,
I have tried all the steps but still the automation is not working with one machine.Kindly help me out in resolving this issue

Thanks,
P.Rajeswari

Posted by: Rajeswari at October 6, 2006 3:27 AM

Rajeswari,

I have followed the steps given by Leo and it's working fine. It's not clear from your message what's the actual problem. Can you please clarify, where you are facing the problem.

Posted by: Manoj Das at October 8, 2006 9:57 PM

I have this normal ftp script that works fine, ftping files from the unix box to a windows box.
#!/usr/bin/ksh
ftp -v -n hostname ftp-gw
Type:xxx@xxx.xxx.com
Type in password when prompted
Ftp>quit
Put C:\temp\filename.txt

Can you help me with this sftp script.

Posted by: Bashir at October 12, 2006 4:17 PM
Comment Page:  1  |  2  |  3  |  4  |  5 
Read the article that everyone's commenting on.
RSS feed Subscribe to the RSS Feed for comments on this article.
Post a Comment

Question? Ask Leo!