Linux – Enter password only once for ssh

command-line-interfacelinuxssh

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/

Best Answer

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