RSSH(1)
okay so first things first: this is rssh(1), and itβs by Derek D. Martin. manual name? folded in right here at the top, bestie π. part 1 is the NAME, SYNOPSIS, and DESCRIPTION era, and more parts are literally on the way, so donβt close the tab π
π NAME π
rssh β restricted secure shell allowing only scp and/or sftp
thatβs the whole name section, short and iconic β¨
β¨ SYNOPSIS β¨
hereβs the summoning syntax, copy it exactly:
rssh [ options... ] [ ... ]
rssh -v
π DESCRIPTION π
okay so rssh is a restricted shell β the whole point is giving limited access to a host via ssh(1). if a userβs shell is configured to be rssh, they can use one or more of these commands: scp(1), sftp(1), cvs(1), rdist(1), and rsync(1). and only those commands. periodt. itβs not a free-for-all, itβs a curated little guest list π
itβs intended primarily to work with OpenSSH (see http://www.openssh.com), but it may work with other implementations too. lowkey flexible.
the system administrator should install the shell on the restricted system. then they edit the password file entry of any user for whom it is desireable to provide restricted access, such that that userβs shell is rssh. for example, it looks like this:
luser:x:666:666::/home/luser:/usr/bin/rssh
if you invoke it with the -v option, rssh will report its version, and exit. thatβs the whole vibe. all the other arguments to rssh are those specified by the remote ssh(1) client β not really something the average user needs to stress about. the arguments provided must be what a shell on the remote end would receive in order to pass control to scp(1), sftp(1), etc.
if rssh receives arguments that donβt conform, it will emit an error message and exit. no cap. and if the program the user is trying to run isnβt allowed, or if it contains syntax that will try to execute a shell command (such as a command substitution), it will also emit an error and exit. so yeah, itβs giving strict gatekeeper energy π₯
rssh also has a configuration file, rssh.conf(5), which allows some of the behavior of rssh to be customized. see that man page for the details, bestie π«Ά
π¨ SECURITY NOTES π¨
okay bestie, read this part with exceptional care, or you may literally put your system at risk π no cap. like, fr fr, this is not the section to skim.
π§ Using rssh With CVS
so if you're using rssh to allow CVS access, ngl you should know: it is not possible to prevent a user who is very familiar with CVS from bypassing rssh and getting a shell β unless that user does not have write access in the repository π. and obviously the user must have write access to the repository in order to update it, which allows them to upload arbitrary programs into the repository. CVS provides several mechanisms for executing such arbitrary programsβ¦ π
the only reasonably safe way to use rssh with CVS is to use the chroot jail facilities to place the CVS repository within a chroot jail π. please see below and all relevant documentation for details of how to set up chroot jails β¨. note that users will still be able to get shell access within the jail; the only protection which is provided is that they can not escape the jail π.
the author has been pursuaded to retain support for CVS because this protection is better than no protection. you have been warned. Use CVS at your own risk. π
π Potential root Compromise With Old Versions
before rssh 2.3.0, if a regular user had shell access to a machine where rssh was installed, a root compromise was possible π± β due to rssh_chroot_helper allowing a user to arbitrarily chroot(2) to anywhere on the filesystem. like, anywhere. yikes.
it is possible to mitigate this attack against affected versions of rssh using strict access controls to files, by making sure that the user can not write to any file on the same partition as system executables, and that any partition where they can write files does not allow execution of SUID programs π«Ά.
as of rssh 2.3.0, this attack has been prevented by preventing arbitrary chroot(), if your jail is set up securely πΈ. in particular, make sure that regular users can not write to directories inside the jail which contain the copied binaries. that should be obvious, but it needs to be said π
.
though it should not be strictly necessary, to further protect your system from possible compromise, it is also advisable to follow the section below, entitled "Safeguards Against Bypassing rssh" β¨.
π‘οΈ Safeguards Against Bypassing rssh
rssh is designed to interact with several other programs. even if rssh is completely bug-free, changes in those other programs could possibly result in methods to circumvent the protection that rssh is intended to provide π¬. so it's important for you, the system administrator, to stay current on the services you make available with rssh, to be sure that these commands do not provide mechanisms to allow the user to run arbitrary commands π₯. also, while the goal of every release is to be bug free, no one is perfectβ¦ there may be undiscovered bugs in rssh which might allow a user to circumvent it π.
you can protect your system from those who would take advantage of such weaknesses πͺ. this is not required for rssh to work properly, but it is a really good idea π. there are six basic steps:
- protect all non-administrator accounts with rssh (i.e. no regular user should have shell access to the server)
- place your users in a chroot jail
- limit the binaries which live in the jail to the absolute minimum required
- mount their home filesystem with the
noexec/nosuidoption (i.e. use separate partitions in the jail for user home directories and all other files, if possible/reasonable) - create a group for rssh users, and limit executable access to the binaries to users in that group.
- use standard file permissions carefully and appropriately
if possible, make sure that no regular user has any kind of shell access to the system other than through rssh π. otherwise, users with shell access could potentially exploit undiscovered bugs in rssh_chroot_helper to gain root access to the server π.
rssh gives the system administrator the ability to place the users in a chroot jail β¨. see details in the man page for rssh.conf and in the file CHROOT which is distributed with the source code. if you want to ensure users can not run arbitrary programs, use a chroot jail, and be sure not to put any programs other than what are absolutely necessary to provide the service you are trying to provide. this prevents them from running standard system commands π«.
then, make sure the user's files inside the jail are on a seperate filesystem from your system's executables π¦. if possible in your environment, make sure you mount this filesystem using the noexec and nosuid options, if your operating system provides them. this prevents the users from being able to execute programs which they have uploaded to the target machine (e.g. using scp) which might otherwise be executable, and prevents SUID programs from respecting the SUID bits π. note that these options necessitate the users' files are on separate partitions from the binaries and libraries that live in the jail. therefore you will need at least 2 partitions for your jail to do this properly (one for the system binaries in the jail, the other for the user directories) π
.
additionally, create a group, for example "rsshuser", for rssh users. put all your users who will be restricted by rssh in that group π. set the ownership and permissions on rssh and rssh_chroot_helper so that only those users can execute them. the following commands should illustrate:
# groupadd rsshuser
# chown root:rsshuser rssh rssh_chroot_helper
# chmod 550 rssh
# chmod 4550 rssh_chroot_helper
lastly, use standard Unix/POSIX file permissions to ensure they can not access files they should not be able to within the chroot jail π.
π Command Line Parser
as of rssh version 2.2.3, the program must parse out the complete command line to avoid command line options which cause the execution of arbitrary programs (and hence bypass the security of rssh) π€. in order to keep the program source code sane, the parser is a little over-zealous about matching command line options π. in practice, this probably will not be an issue, but in theory it is possible.
if you run into a problem where rssh refuses to run, claiming to be rejecting insecure command line options which were not specified, try changing your command line such that all short options are specified as single-letter option flags (e.g. -e -p instead of -ep) and make sure you separate arguments from their respective options by a space (e.g. -p 123 instead of -p123) β¨. in virtually all cases, this should solve the problem π«Ά. admittedly, an exhaustive search was not performed, but no problematical cases were found which were likely to be common.
the alternative would have been to include a complete command-line parser for rcp, rdist, and rsync; this was way out of the scope of this project π. in practice, the existing parser should suffice. if, however, you find cases where it does not, please post details to the rssh mailing list π¬. details about how to post to the mailing list can be found at the rssh homepage πΈ.
π OpenSSH Versions and Bypassing rssh
prior to OpenSSH 3.5, sshd(8) will generally attempt to parse files in the user's home directory, and may also try to run a start-up script from the user's $HOME/.ssh directory π¬. rssh does not make use of the user's environment in any way π
ββοΈ. the relevant command is executed by calling execv(3) with the full path to the command, as specified at compile time. it does not depend upon the user's PATH variable, or on any other environment variable π
there are, however, several problems that can arise. this is due entirely to the way the OpenSSH Project's sshd works, and is in no way the fault of rssh π
. for example, one problem which might exist is that, according to the sshd(8) man page from at least some releases of OpenSSH, the commands listed in the $HOME/.ssh/rc file are executed with /bin/sh instead of the user's defined shell π±. this appears not to be the case on the systems the author had available to test on; commands were executed using the user's configured shell (rssh), which did not allow the execution. however if it is true on your system, then a malicious user may be able to circumvent rssh by uploading a file to $HOME/.ssh/rc which will be executed by /bin/sh on that system π. if any releases (of OpenSSH) are, in fact, vulnerable to this problem, then it is very likely that they are only old, outdated versions. so long as you are running a recent version of OpenSSH, this should not be a problem as far as I can tell β¨.
if your sshd is vulnerable to this attack, there is a workaround for this problem, though it is pretty restrictive π. the user's home directory absolutely must not be writable by the user π«. if it is, the user can use sftp to remove the directory or rename it, and then create a new one, and fill it up with whatever environment files they like π. for providing file uploads, this means a user-writable directory must be created for them, and they must be made aware of their inability to write into their home directory other than in this location.
a second problem is that after authenticating the user, sshd also reads $HOME/.ssh/environment to allow the user to set variables in their environment π. this allows the user to completely circumvent rssh by clever manipulation of such environment variables as LD_LIBRARY_PATH or LD_PRELOAD to link the rssh binary against arbitrary shared libraries π±. in order to prevent this from being a problem, as of version 0.9.3, by default rssh is now compiled statically π. the restrictive work-around mentioned above will also defeat this sort of attack πͺ.
as of OpenSSH 3.5, sshd now supports the option PermitUserEnvironment which is set to "no" by default β. this option allows restricted shells like rssh to function properly without requiring them to be linked statically. as of rssh version 1.0.1, the configure script should detect that OpenSSH 3.5 is present, and disable the default of static compilation πΈ.
π BUGS π
None. =8^)
Literally zero bestie, we're thriving β¨
π«Ά A Note About Getting Help π«Ά
okay so if you're having trouble getting rssh working, or you think you've found a bug, please use the mailing list, and do not e-mail me directly, i'm begging π.
You must sign up for the list in order to post. Info about how to sign up is available on the rssh homepage. And like, if you mail me directly with questions, I will almost certainly ignore you β or at the very least, ask you to repost your question on the mailing list. no cap π
Also please feel free to provide feedback about rssh on the mailing list, whether positive or negative (especially negative). we love a hater, fr fr.
π Security Problems π
The only exception to all of the above is if you believe you've found a security problem with rssh. If that's the case, then please do contact me privately π«‘.
If you're unable to find my direct contact info, post a message on the mailing list requesting that I contact you about a potential security problem. Security problems should be dealt with privately, so that the threat can be properly assessed, and so as not to needlessly endanger the installations of rssh in production environments π₯. I take security problems seriously, and will work to resolve them as quickly as possible. periodt.
π N.B.: π
Before you e-mail me (or the mailing list) with questions, be sure to THOROUGHLY read all of the following files:
READMEINSTALLCHROOTSECURITY
All of these files are distributed with the rssh source code, as well as all binary packages of rssh. If you downloaded a binary package, these files should be located wherever your distribution keeps its documentation files (usually /usr/share/doc/rssh-version/ or something similar) π.
Also THOROUGHLY read the man pages for rssh(1), and rssh.conf(5). Finally, if you're still having problems, read the FAQ at http://www.pizzashack.org/rssh/faq.shtml π.
If it's clear to me that you have not read these documents, I will ignore you π. In most cases, these documents will already have everything you need to get rssh working, and I won't be able to explain it any better on a mailing list than I did in those documentsβ¦ like, i literally already wrote it down bestie, please read it π
π SEE ALSO π
go read the whole fam, they're all iconic π
πΈ and that's the whole page, bestie! this lil masterpiece lives in the man pages collection, dated 1 Aug 2010, and it's known and loved as RSSH(1) π¦ tysm for reading, mwah πβ¨
π¦ where this page comes from
- alpine 3.22: rssh-doc 2.3.4-r4 Β· BSD-2-Clause
- Copyright 2003-2010 Derek D. Martin
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms