Using Ubuntu server, I need to create some user accounts that have the following limitations:
(1) User may only view and manipulate files in their home directory.
(2) User may only execute commands related to rsync and sftp.
I want users to be able to backup files using rsync, and I want them to be able retrieve files using an sftp client like FileZilla.
Other than this, I don't want users to be able to view other files on the system, or execute any commands that might mess with the system.
I'm more of an Ubuntu Desktop user, and have very little experience administering a linux server. Most tutorials I've found assume I know things that I don't know. So I'm having difficulty setting this up.
Everything the user does requires access to large portions of the filesystem. To prove this to yourself, run the following command:
You'll see that listing the contents of your own home directory requires opening and reading at least 40 other files scattered around your system. Other commands, like sftp and such require far broader access.
Unix systems are designed around the concept of users having read-only access to the majority of the OS. With careful permissions and groups, you can easily prohibit them from seeing the contents of each other's directories. With pam_apparmor you would be able to restrict what applications they can run.
EDIT: I just re-read your requirements. It doesn't sound like you need them to be able to log in to a fully interactive shell. If this is the case, there are two ways you could proceed:
aptitude install scponly
. Then set the user's shell to be 'scponly'. Don't let it's name full you; it works with sftp as well. If you want to lock them down even more, look at the documentation in/usr/local/share/doc/scponly
concerning setting up a per-user "chroot".If you need to allow access to more commands than just sftp/scp (like rsync) then you'll need to roll your own command validator and set up an ssh "forced command". Add a block that looks like this to your
/etc/ssh/sshd_config
:Then write the
/usr/local/bin/validate_sftp
script. Something similar to this:Add the user(s) to the "sftponly" group (you'll have to add the group, of course) and they will be restricted to the commands allowed by your script.
I don't know, if this could fit your requirements, but since you say, this should be a server machine, it may be worth thinking about tackling the problem from a different side:
... Just an idea, because there's always a certain security risk involved (and it requires managing user and file permissions) when giving users a system account - at least as long as you don't set up a virtual server for everyone.