[sf-lug] question about using rsync and ssh in a script

Eric Walstad eric at ericwalstad.com
Fri Jul 9 17:43:45 PDT 2010


Hi John,

On Fri, Jul 9, 2010 at 4:45 PM, John Magolske <b79net at gmail.com> wrote:
> I put together a simple script to rsync a couple directories of files
> from a local machine up to a server using rsync & ssh
...
> This ends up prompting me for the same password twice, and I'd like to
> only have to input the password once.

How about not having to input the password at all?  If that's
acceptable then you can use a public/private key pair to enable
password-less logins.  Here's the script I use when creating new key
pairs.  You'll want to edit the variables at the top to your taste
before pasting the contents into a console on your (local) machine.

http://starship.python.net/crew/ewalstad/setup_ssh_keys.html

Once you have your public ssh key ('id_rsa.pub' in my script)
installed on the remote server you will be able to log in without a
password using ssh (and rsync with the -e "ssh" bits).  Remember to
never share your private key ('id_rsa' in my script) - 'Keep it
secret, keep it safe.'

hth,

Eric.




More information about the sf-lug mailing list