Debian Codegraph @

support/rrsync.1.md

raw symbols SCIP
1 ## NAME
2
3 rrsync - a script to setup restricted rsync users via ssh logins
4
5 ## SYNOPSIS
6
7 ```
8 rrsync [-ro|-wo] [-munge] [-absolute] [-no-del] [-no-lock] [-no-overwrite] DIR
9 ```
10
11 The single non-option argument specifies the restricted _DIR_ to use. It can be
12 relative to the user's home directory or an absolute path.
13
14 The online version of this manpage (that includes cross-linking of topics)
15 is available at <https://download.samba.org/pub/rsync/rrsync.1>.
16
17 ## DESCRIPTION
18
19 A user's ssh login can be restricted to only allow the running of an rsync
20 transfer in one of two easy ways:
21
22 * forcing the running of the rrsync script
23 * forcing the running of an rsync daemon-over-ssh command.
24
25 Both of these setups use a feature of ssh that allows a command to be forced to
26 run instead of an interactive shell. However, if the user's home shell is bash,
27 please see [BASH SECURITY ISSUE](#) for a potential issue.
28
29 To use the rrsync script, edit the user's `~/.ssh/authorized_keys` file and add
30 a prefix like one of the following (followed by a space) in front of each
31 ssh-key line that should be restricted:
32
33 > ```
34 > command="rrsync DIR"
35 > command="rrsync -ro DIR"
36 > command="rrsync -munge -no-del DIR"
37 > ```
38
39 Then, ensure that the rrsync script has your desired option restrictions. You
40 may want to copy the script to a local bin dir with a unique name if you want
41 to have multiple configurations. One or more rrsync options can be specified
42 prior to the _DIR_ if you want to further restrict the transfer.
43
44 To use an rsync daemon setup, edit the user's `~/.ssh/authorized_keys` file and
45 add a prefix like one of the following (followed by a space) in front of each
46 ssh-key line that should be restricted:
47
48 > ```
49 > command="rsync --server --daemon ."
50 > command="rsync --server --daemon --config=/PATH/TO/rsyncd.conf ."
51 > ```
52
53 Then, ensure that the rsyncd.conf file is created with one or more module names
54 with the appropriate path and option restrictions. If rsync's
55 [`--config`](rsync.1#dopt) option is omitted, it defaults to `~/rsyncd.conf`.
56 See the [**rsyncd.conf**(5)](rsyncd.conf.5) manpage for details of how to
57 configure an rsync daemon.
58
59 When using rrsync, there can be just one restricted dir per authorized key. A
60 daemon setup, on the other hand, allows multiple module names inside the config
61 file, each one with its own path setting.
62
63 The remainder of this manpage is dedicated to using the rrsync script.
64
65 ## OPTIONS
66
67 0. `-ro`
68
69 Allow only reading from the DIR. Implies [`-no-del`](#opt) and
70 [`-no-lock`](#opt).
71
72 0. `-wo`
73
74 Allow only writing to the DIR.
75
76 0. `-munge`
77
78 Enable rsync's [`--munge-links`](rsync.1#opt) on the server side.
79
80 0. `-absolute`
81
82 Allow file-transfer arguments to name the restricted directory using its
83 absolute server path. For example, with `rrsync -absolute /path/to/root`,
84 the transfer arg `/path/to/root/dir1` is accepted as an alias for `dir1`.
85
86 0. `-no-del`
87
88 Disable rsync's `--delete*` and `--remove*` options.
89
90 0. `-no-lock`
91
92 Avoid the single-run (per-user) lock check. Useful with [`-munge`](#opt).
93
94 0. `-no-overwrite`
95
96 Enforce `--ignore-existing` on the server. Prevents overwriting existing
97 files when the server is the receiver.
98
99 Because `--ignore-existing` protects only the file being transferred, this
100 also refuses the options that can reach a *different* existing file in the
101 restricted dir: `--log-file`, `--partial-dir`, `--delay-updates`, and
102 backup mode (`-b`, `--backup-dir`, whose published backup replaces whatever
103 already occupies the backup name). Resumable uploads with an explicit
104 `--partial-dir`, `--delay-updates`, and server-side logging are therefore
105 unavailable under this option.
106
107 0. `-help`, `-h`
108
109 Output this help message and exit.
110
111 ## SECURITY RESTRICTIONS
112
113 The rrsync script validates the path arguments it is sent to try to restrict
114 them to staying within the specified DIR.
115
116 The rrsync script rejects rsync's [`--copy-links`](rsync.1#opt) option (by
117 default) so that a copy cannot dereference a symlink within the DIR to get to a
118 file outside the DIR.
119
120 The rrsync script rejects rsync's [`--protect-args`](rsync.1#opt) (`-s`) option
121 because it would allow options to be sent to the server-side that the script
122 cannot check. If you want to support `--protect-args`, use a daemon-over-ssh
123 setup.
124
125 The rrsync script accepts just a subset of rsync's options that the real rsync
126 uses when running the server command. A few extra convenience options are also
127 included to help it to interact with BackupPC and accept some convenient user
128 overrides.
129
130 The script (or a copy of it) can be manually edited if you want it to customize
131 the option handling.
132
133 ## BASH SECURITY ISSUE
134
135 If your users have bash set as their home shell, bash may try to be overly
136 helpful and ensure that the user's login bashrc files are run prior to
137 executing the forced command. This can be a problem if the user can somehow
138 update their home bashrc files, perhaps via the restricted copy, a shared home
139 directory, or something similar.
140
141 One simple way to avoid the issue is to switch the user to a simpler shell,
142 such as dash. When choosing the new home shell, make sure that you're not
143 choosing bash in disguise, as it is unclear if it avoids the security issue.
144
145 Another potential fix is to ensure that the user's home directory is not a
146 shared mount and that they have no means of copying files outside of their
147 restricted directories. This may require you to force the enabling of symlink
148 munging on the server side.
149
150 A future version of openssh may have a change to the handling of forced
151 commands that allows it to avoid using the user's home shell.
152
153 ## EXAMPLES
154
155 The `~/.ssh/authorized_keys` file might have lines in it like this:
156
157 > ```
158 > command="rrsync client/logs" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAzG...
159 > command="rrsync -ro results" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAmk...
160 > ```
161
162 ## FILES
163
164 ~/.ssh/authorized_keys
165
166 ## SEE ALSO
167
168 [**rsync**(1)](rsync.1), [**rsyncd.conf**(5)](rsyncd.conf.5)
169
170 ## VERSION
171
172 This manpage is current for version @VERSION@ of rsync.
173
174 ## CREDITS
175
176 rsync is distributed under the GNU General Public License. See the file
177 [COPYING](COPYING) for details.
178
179 An rsync web site is available at <https://rsync.samba.org/> and its github
180 project is <https://github.com/RsyncProject/rsync>.
181
182 ## AUTHOR
183
184 The original rrsync perl script was written by Joe Smith. Many people have
185 later contributed to it. The python version was created by Wayne Davison.