📜 ⬆️ ⬇️

Installing mercurial-server over ssh from source

Universal installation mercurial-server over ssh, from zero to 100%.


I constantly use the aivus topic , but unfortunately it is usually not enough.

I will carry out the configuration for mercurial-server 1.3, fedora 16. If you try to use a post and you have errors, write the system in the comments and the essence of the error, we will solve it.
')

Training


Self install and configure


Installation


Get the source:
wget http://dev.lshift.net/paul/mercurial-server/mercurial-server_1.3.tar.gz tar -xf mercurial-server_1.3.tar.gz cd mercurial-server-1.3 

Install mercurial-server
 python setup.py build python setup.py install 

I prefer to move all the scripts to one place.
 cp scripts*/* /var/lib/mercurial-server/ 

Sshd setup


We need to activate the authorization by public key
 nano /etc/ssh/sshd_config 

Uncomment or add lines
 RSAAuthentication yes PubkeyAuthentication yes 

We will also make a single key storage center
 AuthorizedKeysFile /etc/ssh/keys/%u.pub 
 mkdir /etc/ssh/keys 

Key translation in sshd


All keys of users of the mercurial-server are stored at
/ etc / mercurial-server / keys / at the time of launching refresh-auth (must be run each time a user is added), all keys are written to /var/lib/mercurial-server/.ssh/authorized_keys
What would sshd take these keys do the following
 touch /var/lib/mercurial-server/.ssh/authorized_keys chmod 644 /var/lib/mercurial-server/.ssh/authorized_keys ln /var/lib/mercurial-server/.ssh/authorized_keys /etc/ssh/keys/hg.pub 

Finishing touch


This does not need to be done if you are going to manage keys only through hgadmin!
 touch /usr/bin/hg-update-users chmod 744 /usr/bin/hg-update-users nano /usr/bin/hg-update-users 

 chown hg -R /etc/mercurial-server/keys/ chmod 444 -R /etc/mercurial-server/keys/ sudo -u hg /var/lib/mercurial-server/refresh-auth 

Check


Create the admin key mercurial-server (on the client)
 ssh-keygen scp ~/.ssh/id_rsa.pub root@<b>_</b>:/etc/mercurial-server/keys/root/ ssh root@_ 'hg-update-users' 

If you missed the finishing touch, log in via ssh and execute all commands manually.
Be sure to enter a complex ssh key password! Eliminate the possibility of leakage of the ~ / .ssh / id_rsa file to third parties!
Now check access:
 $ ssh hg@_ PTY allocation request failed on channel 0 <u>mercurial-server: direct logins on the hg account prohibited</u> Connection to _ closed. 

If you received these very lines, then sshd accepts your keys, now try:
 ssh hg@_ 'hg -R hgadmin serve --stdio' 

If within 30 seconds you have not received any errors, then the connection is configured, and you can use your server.

Troubleshooting


For me, the most common mistake (out of three installations: ubuntu 10.04 server, linux mint 12, fedora 16) was the following:
 $ssh hg@_ 'hg -R hgadmin serve --stdio' Traceback (most recent call last): File "/var/lib/mercurial-server/hg-ssh", line 86, in <module> dispatch.dispatch(['-R', repo, 'serve', '--stdio']) File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 31, in dispatch if req.ferr: AttributeError: 'list' object has no attribute 'ferr' 

The solution to this problem can be found at stackoverflow.com/questions/6730735/troubles-with-mercurial-1-9-and-ssh
Particularly lazy can use the patch (patch hg-ssh patch_file):
 --- hg-ssh_old 2012-12-27 00:49:04.764989364 +0300 +++ hg-ssh 2012-12-27 00:50:16.173113572 +0300 @@ -83,7 +83,7 @@ repo = getrepo("read", cmd[6:-14]) if not os.path.isdir(repo + "/.hg"): fail("no such repository %s" % repo) - dispatch.dispatch(['-R', repo, 'serve', '--stdio']) + dispatch.dispatch(dispatch.request(['-R', repo, 'serve', '--stdio'])) elif cmd.startswith('hg init '): repo = getrepo("init", cmd[8:]) if os.path.exists(repo): @@ -91,7 +91,7 @@ d = os.path.dirname(repo) if d != "" and not os.path.isdir(d): os.makedirs(d) - dispatch.dispatch(['init', repo]) + dispatch.dispatch(dispatch.request(['init', repo])) else: fail("illegal command %r" % cmd) 

Source: https://habr.com/ru/post/164095/


All Articles