2

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://bob@mymachine.myhost.com@

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://bob@mymachine.myhost.com/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://bob@mymachine.myhost.com
Relative URL: ^/
Repository Root: svn+ssh://bob@mymachine.myhost.com
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://bob@mymachine.myhost.co/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://bob@mymachine.myhost.com/project
  Relative URL: ^/
  Repository Root: svn+ssh://bob@mymachine.myhost.com/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://bob@mymachine.myhost.com/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://bob@mymachine.myhost.com@

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

svn co svn+ssh://bob@mymachine.myhost.com/trunk

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

Daschm
  • 21
  • 3
  • So you are merging branches on this machine? And getting an error? Why dont you just check the repositories out and merge them on another machine and then just check out a copy on the server for production I assume? THe other option is you could just run a bash script to run $ svn merge ^/trunk branches/alicesbranch you will want to probably give it full paths too. – Daryl B Sep 02 '14 at 09:11
  • No, every other user (like Alice) uses their own computer do work with the repository, and if they have to merge, they merge on their own. And there is the problem: They can't, because as soon as anyone tries to merge on their computer, they cannot connect to the repository anymore. Same for cp ^something. – Daschm Sep 02 '14 at 09:13
  • Could you post the output of `svn info`? – evotion Sep 02 '14 at 09:14
  • Could you try to use the root svn path for `svnserve` `/home/bob/svn` and the ckeckout command `svn co svn+ssh://bob@mymachine.myhost.com/project`? – evotion Sep 02 '14 at 10:11
  • Tried it, did not work (see most recent edit) – Daschm Sep 02 '14 at 12:13
  • @Daschm had you resolved your issue? I'm facing exactly the same one right now. – Vladimir Starkov Mar 19 '15 at 12:12

1 Answers1

0

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://bob@mymachine.myhost.co/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.

evotion
  • 265
  • 2
  • 13
  • If you read my main post, you will see that I defined the key for alice. If I hadn't, she wouldn't be able to connect to the repository at all. The edit just replaced the svnserve part. – Daschm Sep 02 '14 at 12:42
  • Ok sorry, I must have overread it. But did you check the permissions? – evotion Sep 02 '14 at 12:43
  • @Daschm check the new answer. I think this should be the solution. – evotion Sep 02 '14 at 12:56
  • I don't think that the new answer is the solution. Reason: When all public keys are disabled, and Alice enters the normal ssh-password for the account "Bob", she can do everything she wants, including the above commands. Still, I tried to do what you suggested, but I could not check out the trunk or a single branch, see edit 3 of the main post. – Daschm Sep 02 '14 at 15:27
  • @Daschm You missed to specify the project. See the first code line in my answer. It is `user@url/project/trunk` – evotion Sep 02 '14 at 15:37
  • Unfortunately I did not. I just messed up in my edit 3 message [I corrected it]. I also tried it the other way around, i.e. the way you suggest and it does not work: I can check out the full directory, but I cannot check out any subdirectory. – Daschm Sep 02 '14 at 15:45
  • @Daschm Is the directory present on the server? (Did you create the trunk and commited it?) If it is not present, checkout the root of the repository, create the directories trunk and branches (and probably also tags), add them to svn and commit them. After that, try again to checkout the trunk. SVN does not create the folders by itself. – evotion Sep 02 '14 at 16:19
  • I think the problem originates from a completely different source. I mentioned that I only have a finite amount of connections before the server firewall blocks my access for a while, and in the comments of [http://stackoverflow.com/questions/1861518/svnssh-connection-giving-error-210002-network-connection-closed-unexpectedly] someone mentions the same. In my tests, I usually did "svn co ", which worked, and then "svn co " which failed because the firewall most likely already blocked me. I will investigate further, but thank you still for all your help! – Daschm Sep 03 '14 at 12:41