Non-exhuastive tips and advice on server hardening
|
|
il y a 2 ans | |
|---|---|---|
| etc | il y a 2 ans | |
| README.md | il y a 2 ans |
This is not an exhaustive step by step guide to securirty. Instead it is to jog the memory of system administrators, who remain solely responsible for their own security. To give them tips, and hints, or reminders. System admins should do they own research and assume articles they find online are out of date.
Many hosting companies offer a webgui to their customers, here see if you can:
By default users can read files belonging to other users, for isntance in their home directory. If the system is going to be used by multiple peopel taht do not share trust you may consider changing the umask from 022 to 027.
/etc/login.defs to change the line UMASK 022 to UMASK 027
Example file included: ./etc/login.defs/etc/profile: umask 027/etc/skel/.profile, by appending umask 027 to itumask 027 to any ~/.profile files for users that require this umaskapt install libpam-umasksession optional pam_umask.so umask=027 to /etc/pam.d/common-sessionDo not by default use the root account, instead create your own and escallate privileges only when needed.
useradd -m -s /bin/bash USERNAME (Where USERNAME is your username)usermod -aG sudo USERNAMEConsider disconnecting inactive users, as disconnected SSH sessions can be hyjakced.
/etc/profileTMOUT=1800 for a 30 minute timeoutreadonly TMOUT to make users unable to edit their timeoutexport TMOUTAlso append the same to any ~/.profile files for users already created
Example:
TMOUT=1800
readonly TMOUT
export TMOUT
Disable root login and create a group for users who are allowed to login. (There are many bad-faith actors constantly scanning for servers with port 22 open and then try to bruteforce the root password)
groupadd ssh-userusermod -aG ssh-user USERNAME (Where USERNAME is your username)/etc/ssh/sshd_config: nano /etc/ssh/sshd_configAllowGroups ssh-usersudo systemctl restart sshd/etc/ssh/sshd_config again and change #PermitRootLogin prohibit-password to #PermitRootLogin noCiphers and keying, Authentication, settings to modern settings and fitting to your case./etc/ssh/sshd_configIt might be interesting to look at apt-cache search libpam to find other uses for pam that fit your situation.
You can not rely on peolpe using sane and secure passwords, even if they are professionals.
Since Debian 12 pam_cracklib.so/libpam-cracklib is no longer used for this.
sudo apt install libpam-pwqualityman pam_pwquality for the options/etc/pam.d/common-password and edit the line starting with password requisite pam_pwquality.so to your liking
Example file included: ./etc/pam.d/common-passwordDisable passwordless logins for accounts with no password set.
PREVENT_NO_AUTH no to PREVENT_NO_AUTH yes in /etc/login.defsLimit the amount of time a password can be entered before the login is rejected.
LOGIN_RETRIES in /etc/login.defs
Example file included: ./etc/login.defsIn case there is no dataenter firewall via its webgui. Or just for improved/redundant security (Imagine if one layer fails or gets compromised)