| Security Tips |
 |
|
 |
Email to friend
|
 |
Add comment
|
|
|
|
Views: 2569
Votes: 0
Comments: 0
|
Posted: 10 Jun, 2007
by: Customer Service :: S.
* * * * *
Updated: 08 Jan, 2008
by: Customer Service :: S. |
|
The following Security Tips are for generic servers:
(adapted from www.LinuxSecurity.com Web site, posted by Eric Lubow.)
- Secure connection methods
When possible use secure connection methods as opposed to insecure methods. Unless you are required to use telnet, substitute ssh (Secure SHell) in for rsh or telnet. Instead of POP3 or IMAP use SPOP3 or SIMAP (IMAPS). Both SIMAP and SPOP3 are just versions of IMAP and POP3 running over an SSL (Secure Socket
Layer) tunnel.
- TCP_SYNCookies
A SYN-flood attack has the ability to bring the network aspect of your linux
box to a snail-like crawl. TCP_SYNCookies protection attempts to stop this from taking a heavy toll on the machine. To enable tcp_syncookies protection, use the following command:
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
- Turn off spoof protection
To turn on spoof protection, run a simple bash script:
for i in /proc/sys/net/ipv4/conf/*/rp_filter; do echo 1 > $i done;
Be careful to remember that it drops packets more or less 'invisibly'.
- Dealing with empty passwords
Turn off PasswordAuthentication and PermitEmptyPasswords in the SSH configuaration file /etc/ssh/sshd_config. This will ensure that users cannot set empty passwords or login without SSH keys.
PermitEmptyPasswords no PasswordAuthentication no
- Using sudo to replace su
Use sudo to execute commands as root as a replacement for su. In the /etc/sudoers file, add the following lines by using the visudo command:
Cmnd_Alias LPCMDS = /usr/sbin/lpc, /usr/bin/lprm
eric ALL=LPCMDS
Now the user 'eric' can sudo and use the lpc and lprm commands without having any other root level access.
- Quick sudo to root
Users who have sudoer (sudo) accounts setup can have the account setup to change to root without a password. To check this, as root use the following command:
grep NOPASSWD /etc/sudoers
If there is an entry in the sudoers file, it will look like this:
To get rid of this, type visudo and remove the line in that file.
- Password protection with LILO
Password protect your linux install with LILO. Edit your /etc/lilo.conf. At the end of each linux image that you want to secure, put the lines:
read-only
restricted
password = MySecurePassword
Ensure you rereun /sbin/lilo so the changes take effect.
- chattr command
There are files that get changed very infrequently. For instance, if your system won't have any users added anytime soon then it may be sensible to chattr immutably the /etc/password and /etc/shadow files. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
chattr +i /etc/passwd /etc/shadow
- Disallow ICMP
Some attackers, prior to attacking a host
, (or users nmaping a host) will check to see if the host is alive. They do this by 'ping
'ing the host. In order to check if the host is up, they will use an ICMP echo request packet
. To disallow these types of packets, use iptables:
iptables -A INPUT -p icmp --icmp-type echo-request -j DROP
- World writable files
World writable files can be left around by users wanting to make things easier for themselves. It is necessary to be careful about who can write to which files. To find all world writable files:
/usr/bin/find /dir -xdev -perm +o=w ! \( -type d -perm +o=t \) ! -type l -print
- Setuid and Setgid access
Setuid and Setgid files have the potential to be very hazardous if they are accessible by the wrong users on the system. Therefore it is handy to be able to check with files fall into this category. /usr/bin/find /dir -xdev -type f -perm +ug=s -print
- Superuser check
Just in case someone else who has access to the superuser account decided to alter the password file and potentially make themselves a superuser. This is a method to check:
Just in case someone else who has access to the superuser account decided to alter the password file and potentially make themselves a superuser. This is a method to check:
- Passwordless account
Some users like to have a passwordless account. To check this you need to look at the /etc/shadow account with the following command line:
awk -F: '$2 == "" { print $1, "has no password!" }' /etc/shadow
- Default umask
The default umask (usermask) on most systems should be 022 to ensure that files are created with the permissions 0644 (-rw-r--r--). To change the default umask setting for a system, edit /etc/profile to ensure that you umask is appropriate for your setup.
- UsePrivilegeSeparation and StrictModes
Two SSH configuration options that can be set to improve security should be checked on your production server
. UsePrivilegeSeparation is an option, when enabled will allow the OpenSSH server to run a small (necessary) amount of code as root and the of the code in a chroot jail environment. StrictModes checks to ensure that your ssh files and directories have the proper permissions and ownerships before allowing an SSH session to open up. The directives should be set in the /etc/ssh/sshd_config as follows:
UsePrivilegeSeparation yes
StrcitModes yes
- Avoid Accidental Reboot
On a production server that is in a common area (although this should not be the case, some situations are inevidable). To avoid an accidental CTRL-ALT-DEL reboot of the machine, do the following to remove the necessary lines from the /etc/inittab file:
sed -i 's/ca::ctrlaltdel:/#ca::ctrlaltdel:/g' /etc/inittab
- Nmap
Make use of security tools out there to test your server's weaknesses. Nmap is an excellent port scanning tool to test to see what ports you have open. On a remote machine, type the command:
- Skill command
Users who may be acting up or aren't listening can still be controlled. Using a program called 'skill' (signal kill) which is part of the 'procps' package:
Halt/Stop User andy: skill -STOP -u andy
Continue User andy: skill -CONT -u andy
Kill and Logout User andy: skill -KILL -u eric
Kill and Logout All Users: skill -KILL -v /dev/pts/*
|
Last update: December 22nd, 2009 ••• Copyright © 2004-2010 ServerTune Inc.