LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   SCP SSH automatic file transfer (https://www.linuxquestions.org/questions/linux-newbie-8/scp-ssh-automatic-file-transfer-806682/)

smithy2010 05-08-2010 02:41 PM

SCP SSH automatic file transfer
 
Hello all,

I wrote this script in attempt to set-up automatic file fetch from the server using SSH; I want to collect *.pdf files and would like this to happened automatically. However, when I run below script I keep getting prompted for a password, my questions are:

1.can someone advice how to include password in the script and
2.how to export list of transferred files into the log file in txt format



scp root@192.168.1.1:/var/www/html/Apps/*.pdf /media/DataBackup/Linux/imported/ &>/home/denis/Logs/remotefilefetch.sh.out


This script works to a point, however I am prompted for a password and log file is created but remains empty.

Thank you in advance

Denis

colucix 05-08-2010 03:18 PM

Quote:

Originally Posted by smithy2010 (Post 3961555)
1.can someone advice how to include password in the script

Putting your password in clear text inside a script is not a good idea. For passwordless connection you might set-up "public key authentication" (see man ssh, section AUTHENTICATION for details) and use ssh-agent to manage your private keys. There are plenty of tutorials about setting public key auth. Here is one of them.
Quote:

Originally Posted by smithy2010 (Post 3961555)
2.how to export list of transferred files into the log file in txt format

scp doesn't use standard output to display the transfer progress bar. To capture what you see on the terminal, you can try the script command, e.g. by means of something like this:
Code:

script -c "scp command here" file.log
Hope this helps.

smithy2010 05-09-2010 02:00 PM

Hi,

Thanks for your help, I have now configured ssh and private/public key and everything is working as I wanted including log output.

#script -c "scp root@192.168.1.1:/var/www/html/Apps/*.pdf /media/DataBackup/Linux/imported/" /home/denis/Logs/remotefilefetch.log

Best wishes

Denis

colucix 05-09-2010 02:07 PM

You're welcome! I'm glad to know it works! :)


All times are GMT -5. The time now is 03:04 AM.