When it comes to system security, there’s no single correct solution. But with vigilance and these techniques, you will be five steps closer.
On the heels of last week’s entry on using DenyHosts, and Nikto the week before that; I thought it appropriate to continue in the security vein with five more simple techniques that you can use to protect your systems.
These include using account locking, limitingcron use, using DENY access to services, refusing root SSH logins and changing SSHD’s default port.
There’s no excuse to run insecure systems on your network. Your data’s integrity (and your job) depend on your ability to keep those systems running correctly and securely for your co-workers and customers.
Shown here are five simple techniques to make your systems less vulnerable to compromise.
Account Locking
Account locking for multiple failed tries puts extra burden on the system administrators but it also puts some responsibility on the user to remember his passwords.
Additionally, locking allows the administrator to track the accounts that have potential hack attempts against them and to notify those users to use very strong passwords.
Typically, a system will drop your connection after three unsuccessful attempts to login but you may reconnect and try again.
By allowing an infinite number of failed attempts, you’re compromising your system’s security. Smart system administrators can take the following measure to stop this threat: Account lockout after a set number of attempts. My preference is to set that limit to three.
Add the following lines to your system’s /etc/pam.d/system-auth file.
These include using account locking, limitingcron use, using DENY access to services, refusing root SSH logins and changing SSHD’s default port.
There’s no excuse to run insecure systems on your network. Your data’s integrity (and your job) depend on your ability to keep those systems running correctly and securely for your co-workers and customers.
Shown here are five simple techniques to make your systems less vulnerable to compromise.
Account Locking
Account locking for multiple failed tries puts extra burden on the system administrators but it also puts some responsibility on the user to remember his passwords.
Additionally, locking allows the administrator to track the accounts that have potential hack attempts against them and to notify those users to use very strong passwords.
Typically, a system will drop your connection after three unsuccessful attempts to login but you may reconnect and try again.
By allowing an infinite number of failed attempts, you’re compromising your system’s security. Smart system administrators can take the following measure to stop this threat: Account lockout after a set number of attempts. My preference is to set that limit to three.
Add the following lines to your system’s /etc/pam.d/system-auth file.
auth required /lib/security/$ISA/pam_tally.so onerr=fail no_magic_root account required /lib/security/$ISA/pam_tally.so per_user deny=3 no_magic_root reset
Your distribution might not include the system-auth file but instead uses the /etc/pam.d/login file for these entries.
Cron Restriction
If you choose to create these files and add user accounts into them, you also need to create/etc/cron.deny and /etc/at.deny files.
You can leave them empty but they need to exist. Don’t create an empty /etc/cron.deny unless you add entries to the /etc/cron.allow because doing so allows global access to cron. Same goes for at.
To use the allow files, create them in the /etc directory and add one user per line to the file. The root user should have an entry in both allow files. Doing this restricts cron to the root user only.
As the system administrator, you can allow or deny cron and at usage based upon the user’s knowledge and responsibility levels.
Deny, Deny, Deny
System security experts recommend denying all services for all hosts using an all encompassing deny rule in the /etc/hosts.deny file.
The following simple entry (ALL: ALL) gives you the security blanket you need.
# # hosts.deny This file describes the names of the hosts which are # *not* allowed to use the local INET services, as decided # by the '/usr/sbin/tcpd' server. # # The portmap line is redundant, but it is left to remind you that # the new secure portmap uses hosts.deny and hosts.allow. In particular # you should know that NFS uses portmap! ALL: ALL
Edit the /etc/hosts.allow file and insert your network addresses (192.168.1., for example) where you and your users connect from before you logout or you’ll have to login via the console to correct the problem.
Insert entries similar to the following to allow access for an entire network, single host or domain. You can add as many exceptions as you need.
The /etc/hosts.allow file takes precedence over the /etc/hosts.deny to process your exceptions.
Deny SSH by Root
All users should SSH to a system using their standard user accounts and then issue su or sudocommands for proper tracking via system logs.
Open the /etc/ssh/sshd_config file with your favorite editor and change PermitRootLogin yes toPermitRootLogin no and restart the ssh service to accept the change.
Change the Default Port
Some sources suggest changing the default port to a number greater than 1024, for example: 2022, 9922 or something more random, such as 2345.
If you’re going to use this method as one of your strategies, I suggest that you use a port that doesn’t include the number 22.
Edit your /etc/ssh/sshd_config and change the “Port” parameter to your preferred port number. Uncomment the Port line too.
Restart the sshd service when you’re finished and inform your users of the change. Update any applicable firewall rules to reflect the change too.
System security is important and is a constant battle. You have to maintain patch levels, updates and constantly plug newly discovered security holes in system services.
As long as there are black hat wearing malcontents lurking the Net looking for victims, you’ll have a job keeping those wannabe perpetrators at bay.
No comments:
Post a Comment