1 This file describes how to use the sshd "command" directive to set up
2 svn+ssh with any or all of the following properties:
4 (1) Specify a full path to the svnserve binary
5 (2) Specify a repository root as one can with the svnserve daemon
6 (3) Avoid giving full shell access to an svn user
7 (4) Use a single Unix account for multiple svn users
9 This file will assume that the server is using openssh on a Unix-like
10 host. The same tricks may work for other server setups, but changes
11 may need to be made to the details.
13 These tricks require that you use public-key authentication; they will
14 not work with password authentication. These tricks also assume that
15 the client's key-pair is used only for access to svnserve; if you want
16 to retain general shell access to the host, create a second, dedicated
17 key-pair for Subversion access and (assuming a Unix client) set the
18 environment variable SVN_SSH to "ssh -i /path/to/private/key/file".
23 To set up public key authentication on the server, you create a file
24 $HOME/.ssh/authorized_keys, where $HOME is the home directory of the
25 Unix account being used for svnserve on the server. Each line of the
26 file is typically copied from a client's public key file, and looks
29 ssh-rsa AAAABlotsmoregookhere= address@example.com
31 The first field specifies the type of the key, the second is the key
32 itself in uuencoded format, and the third is a comment which humans
33 can use to identify what the key is. In the future, we'll write these
34 three fields as "TYPE KEY COMMENT"
36 The basic trick, then, is to add a directive to this line telling sshd
37 to ignore the client's specified command and run a different command
38 instead. The line in the authorized_keys file will then look like:
40 command="COMMAND" TYPE KEY COMMENT
42 For svn+ssh access, the client generally specifies the command
43 "svnserve -t"; the following tricks will modify the command in various
46 Trick #1: Specify a full path to the svnserve binary
47 ----------------------------------------------------
49 For this trick, specify a command like:
51 command="/full/path/to/svnserve -t" TYPE KEY COMMENT
53 Trick #2: Specify a repository root
54 -----------------------------------
56 For this trick, add a -r option to the svnserve command:
58 command="svnserve -t -r /repository/root" TYPE KEY COMMENT
60 Trick #3: Avoid giving full shell access to an svn user
61 -------------------------------------------------------
63 For this trick, it isn't necessary to modify the command at all. We
64 just need to make sure that the client doesn't run any other commands.
65 However, you should also use the "no-port-forwarding" option to
66 prevent the client from tunneling to other ports:
68 command="svnserve -t",no-port-forwarding TYPE KEY COMMENT
70 You may also wish to specify the options "no-pty",
71 "no-agent-forwarding", and "no-X11-forwarding", just to give the
72 client less wiggle room.
74 Trick #4: Use a single Unix account for multiple svn users
75 ----------------------------------------------------------
77 For this trick, establish a distinct key pair for each of the svn
78 users, list all of the public keys in the authorized_users file, and
79 specify the "--tunnel-user" directive in the command for each entry:
81 command="svnserve -t --tunnel-user=alice" TYPE1 KEY1 COMMENT1
82 command="svnserve -t --tunnel-user=bob" TYPE2 KEY2 COMMENT2
84 As with trick #3, it may be wise to specify "no-port-forwarding" and
85 perhaps the other restriction options to prevent the users from
86 obtaining other kinds of access.
88 The --tunnel-user option is new in svn 1.1.0, so this trick will not
89 work if the server has svn 1.0.x.
94 Here's an example of how you might combine all four tricks:
96 command="/path/to/svnserve -t -r /repository/root --tunnel-user=alice",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty TYPE1 KEY1 COMMENT1
97 command="/path/to/svnserve -t -r /repository/root --tunnel-user=bob",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty TYPE2 KEY2 COMMENT2