Solved

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

Posted on 2008-10-20
3
1,015 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about problems I had with the new location API and permissions in Marshmallow
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now