VPS
Main PagecPanel and DirectAdmin LicensingServer Management PlansVirtual Private ServersDedicated Servers
Control Panel Licensing
ServerTune ResellersResellersSpecial PromotionsServerTune SpecialsHomeAbout ServerTuneContact usTechnical SupportKB
ServerTune Main Page
Space
Space
Our most popular products: Issues, Tips, and Solutions

Protect your server with Mod Security rules written specifically for your system. more info ...

Space
Search:    Advanced search
Browse by category:
Security Tips
Printer Friendly
email to a friend
Add comment Add comment
Views: 899
Votes: 0
Comments: 0
Posted: 10 Jun, 2007
by: Support T.
* * * * *
Updated: 08 Jan, 2008
by: Support T.

The following Security Tips are for generic servers:
(adapted from www.LinuxSecurity.com Web site, posted by Eric Lubow.)

  1. 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.
  2. 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
  3. 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'.
  4. 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
  5. 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.
  6. 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:
      eric ALL=NOPASSWD:ALL
    To get rid of this, type visudo and remove the line in that file.
  7. 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.
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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:
  13. 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
  14. 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.
  15. 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
  16. 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
  17. 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:
      nmap -sTU
  18. 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/*
Other articles in this Category
document Understanding Attack Techniques
document The Concept of Security
document What Causes High Server Load?
document Mod Security Rules and SPAM
document Limit the resources for a specific user
document Denial of Services (DoS) Detrimental to Businesses
document Protect Your Company Against DDoS Attacks
document Malecious Random JavaScript Rootkit
document Protect your server against IFRAME JS injection code with "ServerTune IFrame Shield" Plan
document Latest findings about the Random JavaScript Rootkit
document RKhunter report: The command '/usr/bin/ldd' has been replaced by a script
document Linux kernels v2.6.17+ vmsplice()Root Exploit
document Horde v3.1.6 and earlier is NOT secure
document IFRAME injection code :: infected Web sites and suggestions
document Warning :: A new wave of domain scam/spam
document Your client or your PC might be a zombie in a Botnet



RSS