LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-24-2008, 11:32 AM   #1
dhanju
Member
 
Registered: Aug 2005
Location: bangalore
Posts: 47

Rep: Reputation: 18
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.
Old 07-24-2008, 01:02 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,753

Rep: Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983Reputation: 7983
Quote:
Originally Posted by dhanju View Post
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.
 
Old 07-24-2008, 02:02 PM   #3
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
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
 
Old 07-25-2008, 02:23 AM   #4
dhanju
Member
 
Registered: Aug 2005
Location: bangalore
Posts: 47

Original Poster
Rep: Reputation: 18
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.
Old 12-10-2014, 08:32 AM   #5
opolania
LQ Newbie
 
Registered: Dec 2014
Posts: 1

Rep: Reputation: Disabled
Thumbs up Thanks so Helpfull

Thanks you so much for the previous script. You saved my day.
 
Old 01-16-2023, 04:38 PM   #6
jijawm
LQ Newbie
 
Registered: Nov 2009
Posts: 9

Rep: Reputation: 0
Smile Great Find!

After hours of messing around with .netrc and creating batch files this script gave me the solution I was looking for.
Thanks!
 
Old 01-16-2023, 09:14 PM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,359
Blog Entries: 3

Rep: Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: sshpass - Non-interactive ssh password authentication LXer Syndicated Linux News 0 05-04-2008 04:50 PM
cannot login into SFTP server using Net::SFTP cccc Programming 1 10-31-2007 06:23 AM
interactive and non-interactive shell linuxjamil Programming 3 09-03-2006 08:42 PM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 09:14 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 10:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration