1

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/ [email protected]:/home/folder1/

rsync -ave ssh /opt/lampp/htdocs/new/folder2/ [email protected]:/home/folder2/

rsync -ave ssh /opt/lampp/htdocs/new/folder3/ [email protected]:/home/folder3/

3 Answers 3

11

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

2
  • Can someone expand on this for the beginners? Definitely not for me, Just for the beginners...
    – BenR
    Aug 16, 2020 at 4:17
  • Probably could but I believe key-based authentication is well covered by numerous other questions on serverfault, and tons of articles on Google.
    – Zoredache
    Aug 16, 2020 at 19:43
2

On a bash prompt:

rsync -ave ssh /opt/lampp/htdocs/new/folder{1,2,3} [email protected]:/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 [email protected]:/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..

1

http://linuxproblem.org/art_9.html

This link should assist you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .