LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-08-2010, 03:41 PM   #1
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Rep: Reputation: 15
Smile 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
 
Old 05-08-2010, 04:18 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by smithy2010 View Post
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 View Post
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.
 
Old 05-09-2010, 03:00 PM   #3
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Original Poster
Rep: Reputation: 15
Thumbs up

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

Last edited by smithy2010; 05-09-2010 at 03:02 PM.
 
Old 05-09-2010, 03:07 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
You're welcome! I'm glad to know it works!
 
  


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
How to find whether file transfer has completed on scp or mysqldump. ganesh_k Linux - Newbie 7 08-06-2008 10:00 AM
File transfer stalled after round 40MB (scp, ftp, http, cp) eXor Debian 3 03-26-2008 02:10 PM
cannot transfer (FTP) 10GB file, also scp dont work freebies Linux - Software 2 02-25-2005 01:38 AM
Automatic file transfer c_naranjo Linux - Newbie 3 01-17-2004 05:06 PM
Console hanging and scp transfer low when using ssh XStorm Linux - Networking 1 12-08-2003 10:34 PM


All times are GMT -5. The time now is 03:16 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration