Mercurial and SSH
Sometime ago, we changed our repository to mercurial, for this was a good way to hold a history on all clients.
If you want to connect to a remote repository, your should always consider using SSH.
So here is an example for a connection string with TortoisHg:
[paths]
Default = ssh://username@remote_host//home/username/repository
and keep in mind to use a double slash after the remote host name!
If “username” is a user who is allowed to login on the “remote_host”, this is it.
But you always have to enter the password for this user for every action you undertake.
So what do we need to pull or push without always entering the password?
Keyword is “SSH communication using public and private keys”.
First you have to create your private and public key (see Private and Public SSH Key)
Now you have a privat key in /users/username/.ssh on your windows system and and public key in /home/username/.ssh on your linux server.
Note: The first username is your windows user, the second one the user whom your are using to connect to the linux server, see above in the [path] section.
Now add a new entry in the mercurial.ini file or in your projects hgrc file if you want to use different keys for different projects.
[ui]
username = Mercurial user name
ssh = "C:Program FilesTortoiseHgTortoisePlink.exe" -ssh -2 -batch -C
After done this, you start the application “Pageant.exe” which comes with Tortoise and import your private key.
You have to enter the passphras for this key but only when you import this key.
From now on you can push to or pull from the remote linux repositories without password!
Some people said yout can directly put the key into yout mercurial.ini file like this:
[ui]
ssh = "C:Program FilesTortoiseHgTortoisePlink.exe" -ssh -2 -i "C:Usersusername.sshmy.private.key.ppk"
But this don’t change a bit, because every time Tortoise needs the key, you hav to enter the passphrase.
OK, you can create a private key without passphrase …
Don’t!
Keine Kommentare bisher