LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 12:32 PM   #1
dhanju
Member
 
Registered: Aug 2005
Location: bangalore
Posts: 47

Rep: Reputation: 17
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, 02:02 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,812

Rep: Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148Reputation: 5148
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, 03:02 PM   #3
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,243
Blog Entries: 5

Rep: Reputation: 190Reputation: 190
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, 03:23 AM   #4
dhanju
Member
 
Registered: Aug 2005
Location: bangalore
Posts: 47

Original Poster
Rep: Reputation: 17
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
 
3 members found this post helpful.
Old 12-10-2014, 09: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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 05:50 PM
cannot login into SFTP server using Net::SFTP cccc Programming 1 10-31-2007 07:23 AM
interactive and non-interactive shell linuxjamil Programming 3 09-03-2006 09:42 PM
How do I use sftp to upload my web site? (no sftp tar command) johnMG Linux - Networking 6 06-21-2005 10:14 PM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 11:29 AM

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

All times are GMT -5. The time now is 11:29 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration