It is simple to sync files using Mercurial over SSH.
1. Set up your computer to ssh to the remote computer without a password.
2. Add the following to the .hg/hgrc file (if it doesn’t exist, create it).
default = ssh://user@target:port/path/to/repository
You can now push to default over SSH.
Sometimes you need to create an SSH connection without entering in your password. For instance, you are syncing files using a Version Control System (such as Git or Mercurial) over SSH, and your software isn’t set up to ask for a password every time.
The solution is simple: Store a file on the target computer identifying the source computer.
Here’s how you do it:
1. Generate an SSH key on the source computer (the one you will be making the connection from). When prompted, don’t enter a passphrase.
ssh-keygen -t rsa
2. Create an .ssh directory on the target computer. Enter the ssh password when prompted.
ssh user@Target mkdir -p .ssh
3. Add the source computer’s ssh key to the list of allowed keys on the target computer
cat .ssh/id_rsa.pub | ssh user@Target 'cat >> .ssh/authorized_keys'
You should now be able to make a connection without entering a password.