brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mount /proc with hidepid=2 so users only see their own processes, a security gain

Security
~/tips/tip-security-proc-hidepid

sudo mount -o remount,hidepid=2 /proc

Hides other users' processes and their command lines from normal accounts.

By default every user can run ps aux and read every command line on the box, passwords passed as arguments included. The hidepid mount option stops that.

Try it without a reboot first:

sudo mount -o remount,hidepid=2 /proc
ps aux | wc -l

With hidepid=2 a normal user can’t read the /proc/PID folders of other users, and those folders become invisible as well. ps and top then show only your own processes. Value 1 hides the contents but still shows that the PIDs exist, and 0 is the old default.

To keep it, add a line to /etc/fstab:

proc /proc proc defaults,hidepid=2,gid=adm 0 0

The gid= part names a group whose members still see everything, which is handy for monitoring agents. I use adm here as an example; pick whatever group your monitoring runs in.

This one can bite. Some system services, polkit for example, look at other processes through /proc and can misbehave when they suddenly can’t see them. On a headless server it is usually fine, but test a reboot and a sudo login before you rely on it. Root is never affected.

Further reading: proc(5) manual page

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link