Solved

automatic sftp

Posted on 2006-10-24
5
2,066 Views
Last Modified: 2013-12-26
I want to try automatic sftp of files using a script that runs on cron.

I've used automatic ftp in which you supply username & password too. But sftp seems to be different. Can anyone help me about how to achieve this?

Thanks,
m_razesh.
0
Comment
Question by:m_razesh
5 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 168 total points
ID: 17798448
Make sure that you have setup SSH for passwordless authentication and then it is trivial to use sftp. You might need you system admin's help in getting passwordless authentication to work.

http://acd.ucar.edu/~fredrick/mpark/ssh/rsa-unix.html
http://www.snailbook.com/faq/scripting-sftp.auto.html
0
 
LVL 24

Assisted Solution

by:fridom
fridom earned 166 total points
ID: 17817309
Another option is using ssh-agent, on the client machine and keep the key in it. As long as ssh-agent is running and the key have been added it is like passwordless usage.

Regards
Friedrich
0
 
LVL 1

Assisted Solution

by:jonesstu
jonesstu earned 166 total points
ID: 17818910
sftp uses the ssh protocol for authentication and encryption. You can still use username and password, but that usually means storing the password in plain text on the client end when you are automating it. ssh supports using public/private key authentication so that the user doesn't have to supply a password.

To set up ssh so that it doesn't use passwords:
1. On the client type: ssh-keygen -t rsa
  Accept the defaults, and don't enter a passphrase for the key.
2. Copy the line in ~/.ssh/id_rsa.pub (the public key) to the ~/.ssh/authorized_keys file on the server.
3. Make sure all .ssh/* on both ends are not world readable, writeable or browseable. ( chmod og-rwx .ssh/* )
4. Try it out from the client with:
   ssh <yourserver> ls -l
   It should moan the first time that it doesn't recognise the server. Accept the server's fingerprint. Subsequently it should be ok.
5. sftp should now authenticate automatically too.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now