Solved

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

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 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

12 Experts available now in Live!

Get 1:1 Help Now