Login through ssh or backup with rsync without password

Login to a remote host through ssh without a password

There are a number of reasons why this would be useful. For me it was because I wanted to create an rsync backup job that would run every day at a certain time but I didn’t want the script to wait for me entering my password every time. Warning! This is a bit of a security risk so if you do this, it’s on you own risk.

1. First create a password file with ssh-keygen like this


(just press enter for every option until it’s done)

2. On this step, the “remoteuser@” is set so the user that you want to log in as on the remote host is set. If you skip this, you will log in as the current user on your local machine

ssh-copy-id -i ~/.ssh/id_rsa.pub remoteuser@remotehost.com

If you don’t have the ssh-copy-id command (on a mac) do the following:

curl https://raw.github.com/beautifulcode/ssh-copy-id-for-OSX/master/ssh-copy-id.sh -o /usr/local/bin/ssh-copy-id
chmod +x /usr/local/bin/ssh-copy-id

And don’t forget to thank beautifulcode

3. Now you should be ready. Try it out by typing

ssh remoteuser@remotehost.com