Solved

Creaing a script using SCP to backup from one machine to another.

Posted on 2008-10-20
3
1,017 Views
Last Modified: 2012-05-05
I had started creating a shell script using scp to copy certain directories from one server to another.  My question is... Is it possible for this shell script to type in passwords?  For instance when you use SCP it asks for the password of the user you are using to connect to the remote server with.

See code below for an example of how I am using it.  Now when this runs it prompts for the root password of that server.  However I will be wanting to run this automatically as a cron job.  So is there a way to make the script type in the root password?  Maybe scp has a flag for the password?

Any help would be appreciated.


echo "Attempting back via SCP"
date
echo "Backing up /var/log"
scp -rqp /var/log root@10.1.1.14:/home/serverbackup/Mercury/var
echo "/var/log complete"

Open in new window

0
Comment
Question by:rvpmis
3 Comments
 
LVL 11

Expert Comment

by:jgiordano
ID: 22760134
passwords are a little tricky and require interaction. the expect language is what a lot of people use.

What about trying ssh keys?
0
 
LVL 7

Accepted Solution

by:
namol earned 250 total points
ID: 22760631
The best way to go about this would be to use SSH-Keys, which can be setup by following the directions listed here, http://www.linuxjournal.com/article/8600 .
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 22760650

You could set .ssh trusted connectivity by exchanging the "public" keys.
Look into "authorized_keys" file under the .ssh directory.
Google ssh-keygen and authorized_keys.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to print sub line with  sed /awk /perl in bash file 11 48
EXCHANGE. LINUX, SYMANTEC MESSAGING GATEWAY 2 38
youtube blocking politics 4 55
asp Google Map 2 32
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question