?
Solved

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

Posted on 2008-10-20
3
Medium Priority
?
1,020 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 750 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

752 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