weedo tech blog

le blog technique de la team weedo

  • Home
  • Ka on twitter
    • Edit
    • Delete
    • Tags
    • Autopost

    How to auto-check people with svn using svn+ssh

    It can be interesting to have his author name attributed by the svn server (particularly when using the same login to connect on the svn server over ssh). This post will show you how that can be done.

    This tutorial has been made and used to configure a multi-user svn environment on a OVH shared host (hébergement mutualisé).
    The source guide is available here : http://help.ovh.co.uk/SVNMutu (in english) and here : http://guides.ovh.com/SVNMutu (in french). We push things a bit forward as we explain how to have access both by svn+ssh and by ssh and we resolve a common problem described here : http://forum.ovh.com/showthread.php?t=48610.

    We simplify a bit this tutorial by not using ssh config file, but we’ll try to use ssh config files in another version. If you want more information on ssh config file, type man ssh_config in you terminal or google it.

    As always, feedbacks/comments appreciated.

    Let’s go !

    1) Generating 2 rsa private/public key

    Before configuring server, we need to generate 2 rsa private/public key, one for ssh protocol and one for ssh+svn protocol.

    To do so, do the following on your computer terminal.

    We generate : * a rsa key with the default name (id_rsa) to use it for ssh+svn protocol. * a rsa key with another name (id_rsa_hostname for example) to use it for ssh protocol. This second key is optional but recommended.

    So you’ll have to do that twice :

    prompt$ ssh-keygen -t rsa

    Terminal will answer:

    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/user/.ssh/id_rsa):

    You can enter a new filepath if you want to store the key to another location or with an other name. We suggest having a different key for each host you connect to and giving a meaningful name to your file. Example : /home/user/.ssh/id_rsa_server_name.

    Enter passphrase (empty for no passphrase): Enter same passphrase again:

    Your identification has been saved /home/user/.ssh/in id_rsa_server_name.
    Your public key has been saved in id_rsa_server_name.pub.
    The key fingerprint is:
    5e:13:8c:62:f7:45:12:4g:x6:fd:67:r5:68:s5:78:k4 user@computername
    The key's randomart image is:
    +--[ RSA 2048]----+
    |  . =..+D o      |
    |   . .*=o*       |
    |  . L . .+. .    |
    |   *  .o.+.o     |
    |        X .o     |
    |          .      |
    |                 |
    |                 |
    |                 |
    +-----------------+

    2) Copy public key files to server

    To configure the server you will need the public key you generated previously, so copy it from local to server. To do that you can use scp.

    prompt$ scp path_to_public_key_file login_for_server@server_name:path_you_want_to_copy_file

    3) Connection to server hosting svn

    Launch a terminal and connect to server like that:

    prompt$ ssh yourlogin@yourserver

    You should find the public key files you copy before in the path you specified to scp command.

    4) Configuring server

    First go into folder .ssh located in your home path or create it if not exist.

    yourlogin@yourserver# cd .ssh

    In the folder, open file authorized_keys2 with an editor (emacs, nano, vi, ee). Add the following sentence at the end, replace svnserve_bin_path by the path to svnserve binary (/usr/bin/svnserve ?), home_path by your home path (/homez.XXX/yourlogin ?), root_path by the path you want to be the root for the ssh connection, login_you_want by the login you want svn server attributes to you.

    command="svnserve_bin_path --root=home_path/root_path --tunnel --tunnel-user=login_you_want",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty

    After that add the public key to the same line, you can type this command.

    yourlogin@yourserver# cat path_to_public_key_with_default_name >> authorized_keys2

    Check that the public key has been inserted on the same line with a space as separator that what you added previously to the file.

    For the other public key (the one with the non default name, just copy it on a new line :

    yourlogin@yourserver# cat path_to_public_key_2 >> authorized_keys2

    5) Errors when connecting with command ssh

    Now that you configured the server to attribute author name to one person using svn, if you try to connect to the server over normal ssh connection, you will encounter problems.

    PTY allocation request failed on channel 0
    ( success ( 1 2 ( ANONYMOUS EXTERNAL ) ( edit-pipeline svndiff1 absent-entries ) ) ) Connection to yourserver closed.
    • If you did not make rsa key : To avoid this error, just launch ssh command with -i with an other identifying file path or nothing. ssh -i . yourlogin@yourserver The password will be asked.

    • If you made a rsa key : ssh -i path_to_private_key_2 yourlogin@yourserver The password won’t be asked.

    6) Multi-user

    To auto-attribute author name for other people, repeat this operation. Only one author name can be attributed for the same public key.

    7) Multiple repositories

    You can manage repositories for multiple projects on the same shared host. We ourselves manage 2 multi-users projects on the same shared host.

    8) Test

    svn checkout svn+ssh://yourlogin@yourserver/repository_folder

    (You must not mention here the full path (home_path/root_path), because it is taken from the command parameters in the authorized_keys file.)

    9) Other information resources

    in french : http://doc.fedora-fr.org/wiki/SSH:Authentification_par_cl%C3%A9 in english : http://www.debuntu.org/ssh-key-based-authentication

    • 4 January 2011
    • Views
    • 1 Comment
    • Permalink
    • Favorited 0 Times
    • Tweet
    • Tweet

    Comments 1 Comment

    Apr 24, 2011
    Alex said...
    Bonjour,
    en suivant à la lettre le tuto, et ayant passé la journée à tenter de faire fonctionner tout ça (réussi une fois et en recommençant non), je ne suis pas arrivé au checkout.
    je tombe sur un "No repository found in 'svn+ssh://monloginFTP@mondomaine.fr/monrepository' " .

    quelque chose n'est pas clair pour moi, c'est l'histoire des deux clés public/privée.
    j'ai généré 4 fichiers en tout :
    id_rsa, id_rsa.pub, id_rsa_mondomaine, id_rsa_mondomaine.pub (sachant que pour id_rsa_mondomaine.pub j'ai essayé d'attribuer un mot de passe, pas pour la cléf id_rsa)
    du coup j'ai copié les lignes comme indiqué, mais je ne suis pas sur que ça soit les bons fichier

    je me retrouve avec quelque chose dans le genre dans mon authorized_keys2

    command="/usr/bin/svnserve --root=/homez.xxx/loginFTP/svn --tunnel --tunnel-user=alexmac",no-port-forwarding,no-agent-forwarding,no-x11-forwarding,no-pty AAAAB3NzaC1yc2EAAAABIwAAAQEA0XaJ3CUqrmlGtW5m4M/E+DHypgteEEnWWejwxc2BgY8+2i3sCfDwzR5tcW9C9L9E+Qe1FGBf5gu83IgRpOuWhgK22DUU68SOn3NLkd33GRP5NBmzcjHSPTHPR5UNEZiXwel5NX7dwrC0B5rXQP/jPNGQaEIJTETThsSHFHEiztzQdgo/+Wspzp4mauPWOzdyl2d9RoFXWX0PX1Yn+wdN3cW096ljEHcsPz7g56FBP8jlZ9R78Y05B8CrzjdhSofzbjr+5nFlXCbTKJLhLltkpRzG2pl/AAqTkR7HyJE4ueHXudZLz95putaCCJXbri9dDl6k9x1E6qdrjwHfkJdqew== monusermac@MacBook-Pro-dexxxx.local
    ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxi4Ah9SrdZFA8MbBdwLUucl8hscL9T32MkW73fombeNzu+8jH+DlwFVrEiUiwyjxrf7ofjhdi3pAr8PbXdt+fNsNIhLaAsEtkQ9Woto+sdP54PRn0tewD98/mvT809zR7cfBOwV2gNBfU0jdDEnDWtHIRzs67iDy/bOUaSG7ei3V9IY3mGNg9zuBaXGlenIqBInwDg6ZQft+HAyPydD/0jSaR3Q1akNEVx03eD3swPYu5SXkkAJG0vjUig593H2zUI0hgZdsYjICwb7g/e2tFsSUjVRGMTC7vxk5MQvBz+5WNhBkQTwepXT1/WfiF3CNl1wWqlcyFj9fm2l282ZGbQ== monusermac@MacBook-Pro-dexxxx.local

    Pourriez vous m'éclairez svp?
    merci d'avance,

    cordialement

    Leave a Comment

  • About Karim Cassam Chenaï

    My Google Profile

  • Contributors

    • Ballut Vincent
    • fix
    • Karim Cassam Chenaï
  • Subscribe

    Subscribe to this posterous
    Unsubscribe
    Follow this posterous RSS
    You're a contributor here (Edit)
    This is your Space (Edit)
    Follow by email »
    Get the latest updates in your email box automatically.
  • Follow Me

      Delicious

Theme created for Posterous by Obox