svn+ssh with public key on linux: merge fails but co, up, commit works

1.7k Views Asked by At

I have the following problem: I followed the many tutorials one can find on setting up a public key access via svn+ssh to a subversion repository on a linux machine with ssh-only access. It seems to work for checkouts, updates and commits, but if someone tries to merge or uses the ^ operator to copy, it crashes.

Let me give more information in the form of an example: The svn repository is in the folder /home/bob/svn/project of machine mymachine.myhost.com and belongs to user bob (aka: me). I generated a key for alice and added the following line to /home/bob/.ssh/authorized_keys:

command="/usr/bin/svnserve -t -r /home/bob/svn/project --tunnel-user=Alice",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa <alices key> alice

Alice was able to checkout the repository using

svn co svn+ssh://[email protected]@

She can commit changes and update. However, if she tries to merge or do svn cp using the ^ operator on her machine as follows:

svn cp ^/trunk/ branches/alicesbranch

te server does not react and after a while she gets the following message

svn: E210002: Unable to connect to a repository at URL 'svn+ssh://[email protected]/trunk/'
svn: E210002: To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file.
svn: E210002: Network connection closed unexpectedly

After some research, I gave up, because in most cases I only get discussions from people where the repository could not be accessed at all. However in my case, I/Alice do have access, but not as general as some svn operations Seem to need.

I believe that I did something wrong with the combination of the svnserve command and the path Alice uses to checkout, but I don't know what.

In reality, the server is a machine for which I don't have root access. Also, the network seems to be very shielded from external access: Only ssh is allowed, but as soon as for example the above error occurs, I/Alice cannot login at all on said hostname for a while, probably because the firewall declines access for a while for security reasons because of a failed ssh connection. This is also why I cannot just go ahead and do lots of trial-and-errors with different svnserve commands and different checkout commands, because every error will force me to wait until I can do another trial.

This is why I hope someone here can help me. I hope I gave enough information to pin down the problem.

Sincerly, Daschm

Edit 1: Here is svn info Alice would get

Path: .
Working Copy Root Path: /home/alice/mysvnprojects/myprojectwithbob
URL: svn+ssh://[email protected]
Relative URL: ^/
Repository Root: svn+ssh://[email protected]
Repository UUID: 8f8511ce-d5fa-11e3-abfa-cd5eac3f4aa8
Revision: 121
Node Kind: directory
Schedule: normal
Last Changed Author: Alice
Last Changed Rev: 121
Last Changed Date: 2014-08-22 15:36:56 +0200 (Fri, 22 Aug 2014)

Edit 2: Changing the svnserve command to

command="/usr/bin/svnserve -t -r /home/bob/svn/ --tunnel-user=Alice"

and changing the co command accordingly does not solve the problem. Here is the output:

/home/alice/mysvnprojects/myprojectwithbob: svn co svn+ssh://[email protected]/project
  [looong list of files]
  Checked out revision 129.
/home/alice/mysvnprojects/myprojectwithbob: ls
  project
/home/alice/mysvnprojects/myprojectwithbob: cd project/
/home/alice/mysvnprojects/myprojectwithbob: svn info
  Path: .
  Working Copy Root Path: /home/alice/mysvnprojects/myprojectwithbob
  URL: svn+ssh://[email protected]/project
  Relative URL: ^/
  Repository Root: svn+ssh://[email protected]/project
  Repository UUID: 8f8511ce-d5fa-11e3-abfa-cd5eac3f4aa8
  Revision: 129
  Node Kind: directory
  Schedule: normal
  Last Changed Author: Alice
  Last Changed Rev: 129
  Last Changed Date: 2014-09-02 12:33:56 +0200 (Tue, 02 Sep 2014)
/home/alice/mysvnprojects/myprojectwithbob: ls
  branches  trunk
/home/alice/mysvnprojects/myprojectwithbob: svn cp ^/trunk branches/mytestbranch
  svn: E210002: Unable to connect to a repository at URL     'svn+ssh://[email protected]/project/trunk'
  svn: E210002: To better debug SSH connection problems, remove the -q option from     'ssh' in the [tunnels] section of your Subversion configuration file.
  svn: E210002: Network connection closed unexpectedly

If I do

svn cp ^/trunk ^/branches/mytestbranch

instead, it seems to work! However, I still cannot merge

cd trunk 
svn merge ^/branches/mytestbranch .

leads to the known error.

Edit 3:

It seems as if everything fails which tries to access anything beyond the root directory. For example:

svn co svn+ssh://[email protected]@

works, but [assuming the basic setup where "svnserve -r /home/bob/svn/project" is used]

svn co svn+ssh://[email protected]/trunk

fails. This seems to be a common denominator to all failing and working cases.

1

There are 1 best solutions below

8
On

First you need to create the svn structure, by creating the directories trunk, branches and tags in the root of the project and commit this changes. Otherwise there is obviously no trunk and branches on the server an the ^/trunk and ^/branches/branch commands fail.

The problem is, you are checking out the whole repository instead of the trunk. You are supposed to work on the trunk or the branch and use svn switch to switch between them. To get it work, try to checkout the project with this command:

svn co svn+ssh://[email protected]/project/trunk

If you now try to merge it should work. The problem is, you are trying to merge the whole repository with the branch, which is actually a subfolder of that repository. So to switch to the Alice branch use:

svn switch ^/branches/mytestbranch

If you want want merge it back to trunk, switch back to it first by using

svn switch ^/trunk

And then doing a

svn merge ^/branches/mytestbranch

Checkout a Tutorial of howto use svn and which workflows are best practice.