Article Title: Linux network security tips. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Author: Arthur Reid
Network security is a very important topic. Basically, the more backend services you run, the more security vulnerabilities you may open. if the configuration is appropriate, Linux itself is very secure and reliable. If there is a security defect in the Linux system, because the Linux source code is open, thousands of volunteers immediately discovered and repaired it. This article aims to introduce common techniques used to enhance your network security and uses Redhat Linux as the operating environment.
1. the log file in the operating system is an important clue for detecting network intrusion. Of course, this assumes that your logfile is not damaged by the intruders, if you have a server that uses a leased line to connect directly to the Internet, this means that your IP address is a permanent fixed address, you will find that many people try to telnet/ftp login to your system and try to run # more/var/log/secure | grep refused to check.
2. restrict the number of programs with the SUID permission flag. Programs with this permission flag run as root, which is a potential security vulnerability. Of course, some programs must have this flag, like the passwd program.
3. BIOS security. Set the BIOS password and modify the boot sequence to disable system startup from a floppy disk.
4. User Password. User passwords are the most basic starting point for Linux security. Many users use simple 'Password', which opens the door to intruders, although theoretically there is no uncertain user password, it can be used as long as there is enough time and resources. A good user password is a string of characters that can only be easily remembered and understood by himself, and should never be written anywhere.
5./etc/exports file. If you use the NFS Network File System Service, make sure that your/etc/exports has the strictest access permission settings. This means that you do not use any wildcards and do not allow root write permissions, mount the file to a read-only file system. Edit the/etc/exports file and add: for example:
/Dir/to/export host1.mydomain.com (ro, root_squash)
/Dir/to/export host2.mydomain.com (ro, root_squash)
/Dir/to/export is the directory you want to output, host.mydomain.com is the name of the machine that logs on to this directory, ro means to mount it into a read-only system, and root_squash prohibits root from writing to this directory.
To make the above changes take effect, run/usr/sbin/exportfs-
6. Make sure that the owner of/etc/inetd. conf is root and the File Permission is set to 600.
[Root @ deep] # chmod 600/etc/inetd. conf
ENSURE that the owner is root.
[Root @ deep] # stat/etc/inetd. conf
File: "/etc/inetd. conf"
Size: 2869 Filetype: Regular File
Mode: (0600/-rw -------) Uid: (0/root) Gid: (0/root)
Device: 8, 6 Inode: 18219 Links: 1
Access: Wed Sep 22 16:24:16 1999 (00000.00: 10: 44)
Modify: Mon Sep 20 10:22:44 1999 (00002.06: 12: 16)
Change: Mon Sep 20 10:22:44 1999 (00002.06: 12: 16)
Edit/etc/inetd. conf to disable the following services:
Ftp, telnet, shell, login, exec, talk, ntalk, imap, pop-2, pop-3, finger, auth, etc. unless you really want to use it. In particular, prohibit those r commands. If you use ssh/scp, you can also disable telnet/ftp.
To make the change take effect, run # killall-HUP inetd. You can also run # chattr + I/etc/inetd. conf to make the file have unchangeable attributes. Only the root user can unbind it. Run the # chattr-I/etc/inetd. conf command.
7. TCP_WRAPPERS
By default, Redhat Linux allows all requests. Using TCP_WRAPPERS to enhance the security of your site is a breeze.
"ALL: ALL" to/etc/hosts. deny to prohibit ALL requests, and then put those explicitly allowed requests in/etc/hosts. allow, such:
Sshd: 192.168.1.10/255.255.255.0 gate.openarch.com
The IP address 192.168.1.10 and the host name gate.openarch.com can be connected through ssh. After the configuration is complete, use tcpdchk to check
[Root @ deep] # tcpdchk
Tcpchk is a TCP_Wrapper configuration check tool that checks your tcp wrapper configuration and reports all detected potential/existing problems.
8. Alias file aliases
Edit the alias file/etc/aliases (or/etc/mail/aliases) and delete/comment the following line.
# Basic system aliases -- these MUST be present.
MAILER-DAEMON: postmaster
Postmaster: root
# General redirections for pseudo do accounts.
Bin: root
Daemon: root
# Games: root? Remove or comment out.
# Ingres: root? Remove or comment out.
Nobody: root
# System: root? Remove or comment out.
# Toor: root? Remove or comment out.
# Uucp: root? Remove or comment out.
# Well-known aliases.
# Manager: root? Remove or comment out.
# Dumper: root? Remove or comment out.
# Operator: root? Remove or comment out.
# Trap decode to catch security attacks
# Decode: root
# Person who shocould get roots mail
# Root: marc
After the last update, do not forget to run/usr/bin/newaliases to make the change take effect.
9. Prevent your system from responding to any external/internal ping requests.
Since no one can ping your machine and receive a response, you can greatly enhance the security of your site. You can add the following command to/etc/rc. d/rc. local to run automatically after each startup.
Echo 1>/proc/sys/net/ipv4/icmp_echo_ignore_all
10. Do not display the operating system and version information.
If you want someone to remotely log on to your server without displaying the operating system and version information, you can change
The line in/etc/inetd. conf is as follows:
Telnet stream tcp nowait root/usr/sbin/tcpd in. telnetd-h
Add the-h sign to the end so that the telnet background does not display system information, but only login:
11. The/etc/host. conf file
Edit the host. conf file (vi/etc/host. conf) and add the following line:
# Lookup names via DNS first then fall back to/etc/hosts.
Order bind, hosts
# We don have machines with multiple IP addresses on the same card
(Like virtual server, IP Aliasing ).
Multi off
# Check for IP address spoofing.
Nospoof on
IP Spoofing: IP-Spoofing is a security exploit that works by tricking
Computers in a trust relationship that you are someone that you really aren.
12. The/etc/securetty file
This file specifies the tty device that allows root login./etc/securetty is read by the/bin/login program. Its format is a list of allowed names in a row, for example, you can edit/etc/securetty and comment out the following rows.
Tty1
# Tty2
# Tty3
# Tty4
# Tty5
# Tty6
# Tty7
# Tty8
-This means that the root user is only allowed to log on to the tty1 terminal.
13. Special Account
Disable all accounts that are started by the operating system and do not need it by default. This check should be performed when you install the system for the first time. Linux provides various accounts, which you may not need, if you do not need this account, remove it. The more accounts you have, the more vulnerable you will be to attacks.
To delete users on your system, run the following command:
[Root @ deep] # userdel username
To delete a group user account on your system, run the following command:
[Root @ deep] # groupdel username
Run the following command on the terminal to delete the following users.
[Root @ deep] # userdel adm
[Root @ deep] # userdel lp
[Root @ deep] # userdel sync
[Root @ deep] # userdel shutdown
[Root @ deep] # userdel halt
[Root @ deep] # userdel mail
If you do not need the sendmail server, procmail. mailx, delete this account.
[Root @ deep] # userdel news
[Root @ deep] # userdel uuucp
[Root @ deep] # userdel operator
[Root @ deep] # userdel games
If you do not need X windows Server, delete this account.
[Root @ deep] # userdel gopher
[Root @ deep] # userdel ftp
If you do not allow anonymous FTP, delete this user account.
===
Run the following command to delete a group account:
[Root @ deep] # groupdel adm
[Root @ deep] # groupdel lp
[Root @ deep] # groupdel mail
If you do not need the Sendmail server, delete this group account.
[Root @ deep] # groupdel news
[Root @ deep] # groupdel uuucp
[Root @ deep] # groupdel games
If you do not need X Windows, delete this group account.
[Root @ deep] # groupdel dip
[Root @ deep] # groupdel pppusers
[Root @ deep] # groupdel popusers
If you do not need a POP server, delete this group account.
[Root @ deep] # groupdel slipusers
====
Use the following command to add the Required User Account
[Root @ deep] # useradd username
Use the following command to change the User Password
[Root @ deep] # passwd username
Use the chattr command to add unchangeable attributes to the following files.
[Root @ deep] # chattr + I/etc/passwd
[Root @ deep] # chattr + I/etc/shadow
[Root @ deep] # chattr + I/etc/group
[Root @ deep] # chattr + I/etc/gshadow
14. prevent anyone from using su as root.
If you don't want anyone to use su as the root user, you can edit/etc/pam. d/su and add the following lines:
Auth sufficient/lib/security/pam_rootok.so debug
Auth required/lib/security/pam_wheel.so group = isd
This means that only users in the isd group can use su as root. Then, if you want the user admin to use su as root, run the following command.
[Root @ deep] # usermod-G10 admin
16. resource restrictions
Set all users on your system
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service