Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-24-2008, 11:32 AM
|
#1
|
Member
Registered: Aug 2005
Location: bangalore
Posts: 47
Rep:
|
SFTP with non-interactive authentication
Hi
I want to write a script to do the file transfer using SFTP. How to pass pasword to SFTP in the script. So that i can schedule the for automating file transfer.
Kindly provide me a solution for this.
Thanks In Advance
Dhanju
|
|
|
Click here to see the post LQ members have rated as the most helpful post in this thread.
|
07-24-2008, 01:02 PM
|
#2
|
LQ Guru
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,712
|
Quote:
Originally Posted by dhanju
Hi
I want to write a script to do the file transfer using SFTP. How to pass pasword to SFTP in the script. So that i can schedule the for automating file transfer.
Kindly provide me a solution for this.
|
Since it's using SSH, you should be able to do an SSH keyswap between the machines. You don't say what you're writing the script/program in, or on what version of linux, so it's hard to "kindly provide you a solution", but if it's PERL, check out the Net::SFTP module on CPAN.
|
|
|
07-24-2008, 02:02 PM
|
#3
|
LQ Guru
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Rep: 
|
I know we don't typically link to a different forum, but there's a nice scripting example snippet in the UNIX Shell programming scripting forum for using key based authentication in a sftp script.
http://www.unix.com/shell-programmin...-required.html
|
|
|
07-25-2008, 02:23 AM
|
#4
|
Member
Registered: Aug 2005
Location: bangalore
Posts: 47
Original Poster
Rep:
|
SFTP Non-interactive Mode
Hi
Thanks for all your suggestions, i got the solution for SFTP non-interactive mode is as follows
#!/bin/sh
HOST=XX.XXXX.XXX
USER=yourusername
PASS=yourpassword
echo "Starting to sftp..."
lftp -u ${USER},${PASS} sftp://${HOST} <<EOF
cd somedir
get somefile
bye
EOF
echo "done"
Thanks
Dhanju
|
|
4 members found this post helpful.
|
12-10-2014, 08:32 AM
|
#5
|
LQ Newbie
Registered: Dec 2014
Posts: 1
Rep: 
|
Thanks so Helpfull
Thanks you so much for the previous script. You saved my day.
|
|
|
01-16-2023, 04:38 PM
|
#6
|
LQ Newbie
Registered: Nov 2009
Posts: 9
Rep:
|
Great Find!
After hours of messing around with .netrc and creating batch files this script gave me the solution I was looking for.
Thanks!
|
|
|
01-16-2023, 09:14 PM
|
#7
|
LQ Guru
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,756
|
You do realize two things about this thread, right? First is that it is getting near 15 years old. Second that FTP is the wrong solution for just about anything these days and the correct answer was the SFTP client using the -i and -b options or setting the equivalent in ~/.ssh/config. It's 2023, don't use FTP.
|
|
|
All times are GMT -5. The time now is 03:14 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|