Stumbled this as I was looking a solution for something else...
My take is that you can just do:
chmod 711 /home
chmod 711 /home/*
and this should at least prevent other users from listing the /home directory. These are not recursive and will only protect /home and /home/userX or /home/userY from being listed (ls) directly.
Of course an unprivileged user can just cat /etc/passwd
and view all users in the system, in which case, it's as good as listing the /home directory probably...
In such a case, I highly recommend Firejail which was built for this exactly and it's easy to setup.
On Ubuntu Server, you would install and configure it like this (e.g. in a firejail_install.sh script):
#!/bin/bash
apt-get -y update
apt-get -y install firejail
if [ ! -f "/etc/firejail/disable-common.local" ]; then
cat > "/etc/firejail/disable-common.local" <<EOF
# Firejail blacklist
blacklist /etc/passwd
blacklist /etc/letsencrypt
blacklist /etc/mysql
blacklist /etc/nginx
blacklist /etc/php
blacklist /etc/postfix
blacklist /etc/varnish
blacklist /var/lib/mysql
blacklist /var/run/php
# END
EOF
fi
Just be careful what you blacklist :)
This, combined with the right permissions on /home should be enough to somewhat better protect your system from prying eyes.