Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use the following commands to sync folders. Each command requires me to type in the password. How can I group these commands to only enter the password once? Thanks.

rsync -ave ssh /opt/lampp/htdocs/new/folder1/ root@111.111.111.111:/home/folder1/

rsync -ave ssh /opt/lampp/htdocs/new/folder2/ root@111.111.111.111:/home/folder2/

rsync -ave ssh /opt/lampp/htdocs/new/folder3/ root@111.111.111.111:/home/folder3/

share|improve this question

3 Answers 3

up vote 11 down vote accepted

Setup key-based authentication, and use an ssh-agent.

share|improve this answer

On a bash prompt:

rsync -ave ssh /opt/lampp/htdocs/new/folder{1,2,3} root@111.111.111.111:/home/

If you do folder{1,2,3}/ the wrong thing will happen..

This is the same command in a more verbose version:

 rsync -ave ssh /opt/lampp/htdocs/new/folder1 /opt/lampp/htdocs/new/folder2 /opt/lampp/htdocs/new/folder3 root@111.111.111.111:/home/

Using Authorized_keys

You can also add command specific public keys, add this to authorized_keys:

command="rsync --server -vldogDtpr --partial . /home/",no-pty,no-agent-forwarding,no-port-forwarding ssh-rsa AA[...]3RIy/FbGhV5Xg1jILhhgb[...]iTqYKj/FgF0+vZJaQ== erik@myhost

Problem is I don't know how to limit rsync to just allowing transfering to folder1,2,3..

share|improve this answer

http://linuxproblem.org/art_9.html

This link should assist you.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.