10

[02:48][root@server:~] ps ax | grep svn 23986 ? Ss 0:00 /usr/bin/svnserve -d -r /srv/svn As you see from arguments my svn root dir is /srv/svn.

Now, some magic from remote machine...

This works:

> svn co svn://svn-user@domain.com/test-repo

But this not:

> svn co svn+ssh://svn-user@<putty-session-name>/test-repo
'No repository found in 'svn+ssh://svn-user@<putty-session-name>/test-repo'

Playing around for couple of hours I've found that appearantly if I use ssh tunnel, I'm able to get my repo using following:

> svn co svn+ssh://svn-user@<putty-session-name>/srv/svn/test-repo

...which means that I should specify full physical path to the repo. Huh?

Andrejs Cainikovs
  • 1,611
  • 1
  • 14
  • 20

4 Answers4

13

As womble have said, indeed this is the 'feature' of svn over ssh.

I had svn+ssh working without specifying the full path to repositories because the svn server had a svnserve wrapper script in place of original svnserve binary. Later, during subversion update this script was overwritten by the original binary.

Solution:

  1. Rename svnserve to bin

    mv /usr/bin/svnserve /usr/bin/svnserve.bin
    
  2. Save this script as /usr/bin/svnserve:

    #!/bin/sh
    exec /usr/bin/svnserve.bin -r /srv/svn "$@"
    
  3. Update permissions

    chmod 755 /usr/bin/svnserve
    
Andrejs Cainikovs
  • 1,611
  • 1
  • 14
  • 20
  • 1
    I had the same issue except reverse. I spent hours trying to figure out why i couldn't do svn+ssh://host/path/to/repo because I had a script being ran that automatically directed me to the svn root. All I needed to do was svn+ssh://host/repo. – Bot Feb 02 '11 at 20:50
  • Could root be set as a variable, and then have some logic that removes the root from $@ if it is mistakenly provided? It would prevent issue's like @Bot 's. – MattPark Jun 24 '13 at 18:00
5

That's because svn over SSH (svn+ssh://) is just accessing a subversion repository "locally", using SSH as the transport, and hence you have access to the entire filesystem. Svnserve, in contrast, is told "start your paths with /srv/svn, and so you don't have to specify it manually.

womble
  • 95,029
  • 29
  • 173
  • 228
3

You can edit the ssh login command for users using svn+ssh, by editing the ~/.ssh/authorized_keys of the subversion user. The line for a user will looks like :

command="/usr/bin/svnserve -r /srv/svn [other svnserve options]" <key type> <user key> <key comment>

There are more svn+ssh tricks in the svn book

slubman
  • 2,247
  • 16
  • 11
0

this is more like a question by itself, but it is really related to this one.

having set up svn+ssh with private/public keys i can't access my repo using relative paths in this way:

svn co svn+ssh://svn@SERVERIP/simple-webapp-svn simple-webapp-svn

since i am getting this error:

svn: URL 'svn+ssh://svn@SERVERIP/simple-webapp-svn' doesn't exist

but only like that:

svn co svn+ssh://svn@SERVERIP/home/svn/projects/simple-webapp-svn simple-webapp-svn

This is the authorized_keys2 file i have inside /home/svn/.ssh directory

$ sudo cat /home/svn/.ssh/authorized_keys2
command="/usr/bin/svnserve.bin -t --tunnel-user=USERNAME",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa [rsa-key] [user-note]

and the svnserve.bin file suggested by Andrejs at previous answer

$ cat  /usr/bin/svnserve.bin 
#!/bin/sh
exec /usr/bin/svnserve -r /home/svn/projects "$@"

I even thought about permission issues, that are listed here:

-rwxr-xr-x 1 root root 63684 2009-12-12 06:45 /usr/bin/svnserve
-rwxr-xr-x 1 root root    61 2010-08-25 17:19 /usr/bin/svnserve.bin

I really can't come up with a solution...

mox601
  • 133
  • 2
  • 8
  • You didn't read my answer correctly. You should rename svnserve binary to svnserve.bin, and save the wrapper script you have there as svnserve. Or simply, contents of both your files should be swapped. – Andrejs Cainikovs Aug 26 '10 at 08:19
  • I think that calling svnserve.bin from authorized_keys2 and in that file executing svnserve should be exactly the same, isn't it? I did like that to prevent renaming svnserve binary, do you think it is wrong? – mox601 Aug 26 '10 at 08:36