Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1021
  • Last Modified:

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

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
rvpmis
Asked:
rvpmis
1 Solution
 
jgiordanoCommented:
passwords are a little tricky and require interaction. the expect language is what a lot of people use.

What about trying ssh keys?
0
 
namolCommented:
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
 
MikeOM_DBACommented:

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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now