Debian Codegraph @

rrsync.1.html

raw
1 <html><head>
2 <title>rrsync(1) manpage</title>
3 <meta charset="UTF-8"/>
4 <link href="https://fonts.googleapis.com/css2?family=Roboto&family=Roboto+Mono&display=swap" rel="stylesheet">
5 <style>
6 body {
7 max-width: 50em;
8 margin: auto;
9 }
10 body, b, strong, u {
11 font-family: 'Roboto', sans-serif;
12 }
13 a.tgt { font-face: symbol; font-weight: 400; font-size: 70%; visibility: hidden; text-decoration: none; color: #ddd; padding: 0 4px; border: 0; }
14 a.tgt:after { content: '🔗'; }
15 a.tgt:hover { color: #444; background-color: #eaeaea; }
16 h1:hover > a.tgt, h2:hover > a.tgt, h3:hover > a.tgt, dt:hover > a.tgt { visibility: visible; }
17 code {
18 font-family: 'Roboto Mono', monospace;
19 font-weight: bold;
20 white-space: pre;
21 }
22 pre code {
23 display: block;
24 font-weight: normal;
25 }
26 blockquote pre code {
27 background: #f1f1f1;
28 }
29 dd p:first-of-type {
30 margin-block-start: 0em;
31 }
32 </style>
33 </head><body>
34 <h2 id="NAME">NAME<a href="#NAME" class="tgt"></a></h2>
35 <p>rrsync -&#8288; a script to setup restricted rsync users via ssh logins</p>
36 <h2 id="SYNOPSIS">SYNOPSIS<a href="#SYNOPSIS" class="tgt"></a></h2>
37 <pre><code>rrsync [-ro|-wo] [-munge] [-no-del] [-no-lock] [-no-overwrite] DIR
38 </code></pre>
39 <p>The single non-option argument specifies the restricted <u>DIR</u> to use. It can be
40 relative to the user's home directory or an absolute path.</p>
41 <p>The online version of this manpage (that includes cross-linking of topics)
42 is available at <a href="https://download.samba.org/pub/rsync/rrsync.1">https://download.samba.org/pub/rsync/rrsync.1</a>.</p>
43 <h2 id="DESCRIPTION">DESCRIPTION<a href="#DESCRIPTION" class="tgt"></a></h2>
44 <p>A user's ssh login can be restricted to only allow the running of an rsync
45 transfer in one of two easy ways:</p>
46 <ul>
47 <li>forcing the running of the rrsync script</li>
48 <li>forcing the running of an rsync daemon-over-ssh command.</li>
49 </ul>
50 <p>Both of these setups use a feature of ssh that allows a command to be forced to
51 run instead of an interactive shell. However, if the user's home shell is bash,
52 please see <a href="#BASH_SECURITY_ISSUE">BASH SECURITY ISSUE</a> for a potential issue.</p>
53 <p>To use the rrsync script, edit the user's <code>~/.ssh/authorized_keys</code> file and add
54 a prefix like one of the following (followed by a space) in front of each
55 ssh-key line that should be restricted:</p>
56 <blockquote>
57 <pre><code>command=&quot;rrsync DIR&quot;
58 command=&quot;rrsync -ro DIR&quot;
59 command=&quot;rrsync -munge -no-del DIR&quot;
60 </code></pre>
61 </blockquote>
62 <p>Then, ensure that the rrsync script has your desired option restrictions. You
63 may want to copy the script to a local bin dir with a unique name if you want
64 to have multiple configurations. One or more rrsync options can be specified
65 prior to the <u>DIR</u> if you want to further restrict the transfer.</p>
66 <p>To use an rsync daemon setup, edit the user's <code>~/.ssh/authorized_keys</code> file and
67 add a prefix like one of the following (followed by a space) in front of each
68 ssh-key line that should be restricted:</p>
69 <blockquote>
70 <pre><code>command=&quot;rsync --server --daemon .&quot;
71 command=&quot;rsync --server --daemon --config=/PATH/TO/rsyncd.conf .&quot;
72 </code></pre>
73 </blockquote>
74 <p>Then, ensure that the rsyncd.conf file is created with one or more module names
75 with the appropriate path and option restrictions. If rsync's
76 <a href="rsync.1#dopt--config"><code>--config</code></a> option is omitted, it defaults to <code>~/rsyncd.conf</code>.
77 See the <a href="rsyncd.conf.5"><strong>rsyncd.conf</strong>(5)</a> manpage for details of how to
78 configure an rsync daemon.</p>
79 <p>When using rrsync, there can be just one restricted dir per authorized key. A
80 daemon setup, on the other hand, allows multiple module names inside the config
81 file, each one with its own path setting.</p>
82 <p>The remainder of this manpage is dedicated to using the rrsync script.</p>
83 <h2 id="OPTIONS">OPTIONS<a href="#OPTIONS" class="tgt"></a></h2>
84 <dl>
85
86 <dt id="opt-ro"><code>-ro</code><a href="#opt-ro" class="tgt"></a></dt><dd>
87 <p>Allow only reading from the DIR. Implies <a href="#opt-no-del"><code>-no-del</code></a> and
88 <a href="#opt-no-lock"><code>-no-lock</code></a>.</p>
89 </dd>
90
91 <dt id="opt-wo"><code>-wo</code><a href="#opt-wo" class="tgt"></a></dt><dd>
92 <p>Allow only writing to the DIR.</p>
93 </dd>
94
95 <dt id="opt-munge"><code>-munge</code><a href="#opt-munge" class="tgt"></a></dt><dd>
96 <p>Enable rsync's <a href="rsync.1#opt--munge-links"><code>--munge-links</code></a> on the server side.</p>
97 </dd>
98
99 <dt id="opt-no-del"><code>-no-del</code><a href="#opt-no-del" class="tgt"></a></dt><dd>
100 <p>Disable rsync's <code>--delete*</code> and <code>--remove*</code> options.</p>
101 </dd>
102
103 <dt id="opt-no-lock"><code>-no-lock</code><a href="#opt-no-lock" class="tgt"></a></dt><dd>
104 <p>Avoid the single-run (per-user) lock check. Useful with <a href="#opt-munge"><code>-munge</code></a>.</p>
105 </dd>
106
107 <dt id="opt-no-overwrite"><code>-no-overwrite</code><a href="#opt-no-overwrite" class="tgt"></a></dt><dd>
108 <p>Enforce <code>--ignore-existing</code> on the server. Prevents overwriting existing
109 files when the server is the receiver.</p>
110 </dd>
111
112 <span id="opt-h"></span><dt id="opt-help"><code>-help</code>, <code>-h</code><a href="#opt-help" class="tgt"></a></dt><dd>
113 <p>Output this help message and exit.</p>
114 </dd>
115 </dl>
116 <h2 id="SECURITY_RESTRICTIONS">SECURITY RESTRICTIONS<a href="#SECURITY_RESTRICTIONS" class="tgt"></a></h2>
117 <p>The rrsync script validates the path arguments it is sent to try to restrict
118 them to staying within the specified DIR.</p>
119 <p>The rrsync script rejects rsync's <a href="rsync.1#opt--copy-links"><code>--copy-links</code></a> option (by
120 default) so that a copy cannot dereference a symlink within the DIR to get to a
121 file outside the DIR.</p>
122 <p>The rrsync script rejects rsync's <a href="rsync.1#opt--protect-args"><code>--protect-args</code></a> (<code>-s</code>) option
123 because it would allow options to be sent to the server-side that the script
124 cannot check. If you want to support <code>--protect-args</code>, use a daemon-over-ssh
125 setup.</p>
126 <p>The rrsync script accepts just a subset of rsync's options that the real rsync
127 uses when running the server command. A few extra convenience options are also
128 included to help it to interact with BackupPC and accept some convenient user
129 overrides.</p>
130 <p>The script (or a copy of it) can be manually edited if you want it to customize
131 the option handling.</p>
132 <h2 id="BASH_SECURITY_ISSUE">BASH SECURITY ISSUE<a href="#BASH_SECURITY_ISSUE" class="tgt"></a></h2>
133 <p>If your users have bash set as their home shell, bash may try to be overly
134 helpful and ensure that the user's login bashrc files are run prior to
135 executing the forced command. This can be a problem if the user can somehow
136 update their home bashrc files, perhaps via the restricted copy, a shared home
137 directory, or something similar.</p>
138 <p>One simple way to avoid the issue is to switch the user to a simpler shell,
139 such as dash. When choosing the new home shell, make sure that you're not
140 choosing bash in disguise, as it is unclear if it avoids the security issue.</p>
141 <p>Another potential fix is to ensure that the user's home directory is not a
142 shared mount and that they have no means of copying files outside of their
143 restricted directories. This may require you to force the enabling of symlink
144 munging on the server side.</p>
145 <p>A future version of openssh may have a change to the handling of forced
146 commands that allows it to avoid using the user's home shell.</p>
147 <h2 id="EXAMPLES">EXAMPLES<a href="#EXAMPLES" class="tgt"></a></h2>
148 <p>The <code>~/.ssh/authorized_keys</code> file might have lines in it like this:</p>
149 <blockquote>
150 <pre><code>command=&quot;rrsync client/logs&quot; ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAzG...
151 command=&quot;rrsync -ro results&quot; ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAmk...
152 </code></pre>
153 </blockquote>
154 <h2 id="FILES">FILES<a href="#FILES" class="tgt"></a></h2>
155 <p>~/.ssh/authorized_keys</p>
156 <h2 id="SEE_ALSO">SEE ALSO<a href="#SEE_ALSO" class="tgt"></a></h2>
157 <p><a href="rsync.1"><strong>rsync</strong>(1)</a>, <a href="rsyncd.conf.5"><strong>rsyncd.conf</strong>(5)</a></p>
158 <h2 id="VERSION">VERSION<a href="#VERSION" class="tgt"></a></h2>
159 <p>This manpage is current for version 3.4.4 of rsync.</p>
160 <h2 id="CREDITS">CREDITS<a href="#CREDITS" class="tgt"></a></h2>
161 <p>rsync is distributed under the GNU General Public License. See the file
162 <a href="COPYING">COPYING</a> for details.</p>
163 <p>An rsync web site is available at <a href="https://rsync.samba.org/">https://rsync.samba.org/</a> and its github
164 project is <a href="https://github.com/RsyncProject/rsync">https://github.com/RsyncProject/rsync</a>.</p>
165 <h2 id="AUTHOR">AUTHOR<a href="#AUTHOR" class="tgt"></a></h2>
166 <p>The original rrsync perl script was written by Joe Smith. Many people have
167 later contributed to it. The python version was created by Wayne Davison.</p>
168 <div style="float: right"><p><i>8 Jun 2026</i></p></div>
169 </body></html>