I want to run an old school shell server for a couple of people, ie. one where users get ssh access so they can run software (their own or provided). My concern is appropriate separation between users.
I don't want them to view each other processes, access each other's files (unless explicitly allowed), etc. It would be nice to not get bitten by every privilege escalation bug or restart the server with every minor kernel update. It would be perfect to maintain the option of running common services (like web and mail hosting) with these security measures in place.
Back in the day I used grsec but this requires staying on an older kernel and dealing with the hassle of compiling it yourself. Is there a more modern and more Ubuntu way of ensuring user separation on a shared server?
Perhaps you can do something with AppArmor to that effect? Or maybe there is a repository of kernels pre-configured for shared environments? Or a solution based on containers? These have been en vogue lately.
hidepid
procfs
on Linux now supports thehidepid
option. Fromman 5 proc
:So, mounting
/proc
withhidepid=2
is enough to hide the details of other users' processes on Linux > 3.3. Ubuntu 12.04 comes with 3.2 by default, but you can install newer kernels. Ubuntu 14.04 and above easily match this requirement.ACLs
As a first step, remove
rwx
permissions for others from every home directory (and for group as well, if you require it). I'm assuming, of course, that the folder(s) containing the home directories don't have write permissions to anybody except root.Then, grant services like the web server and mail server access to the appropriate directories using ACLs. For example, to grant the web server process access to the user home pages, assuming
www-data
is the user and~/public_html
is where the home page is kept:Similarly, add ACLs for the mail processes and the mailbox directories.
ACLs are enabled by default on ext4 at least on Ubuntu 14.04 and above.
/tmp
andumask
Another problem is
/tmp
. Set theumask
so that files aren't group- or world-readable, so that users' temporary files aren't accessible to other users.With these three settings, users shouldn't be able to access other users' files, or examine their processes.