LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   SFTP with non-interactive authentication (https://www.linuxquestions.org/questions/linux-server-73/sftp-with-non-interactive-authentication-657992/)

dhanju 07-24-2008 11:32 AM

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

TB0ne 07-24-2008 01:02 PM

Quote:

Originally Posted by dhanju (Post 3225102)
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.

farslayer 07-24-2008 02:02 PM

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

dhanju 07-25-2008 02:23 AM

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

opolania 12-10-2014 08:32 AM

Thanks so Helpfull
 
Thanks you so much for the previous script. You saved my day.

jijawm 01-16-2023 04:38 PM

Great Find!
 
After hours of messing around with .netrc and creating batch files this script gave me the solution I was looking for.
Thanks!

Turbocapitalist 01-16-2023 09:14 PM

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 06:49 PM.