CentOS server security configuration

Source: Internet
Author: User
Among the many servers, the CentOS server is a leader. with its own advantages, the CentOS server has won the support of many netizens. So how can we ensure the security of the CentOS server? Next, we will provide a good solution to some security issues of the CentOS server. 1. use a firewall to close unnecessary ports. if someone else fails to PING the server, the threat is naturally reduced by more than half. How to prevent others from pinging: 1) run the command prompt, 0 indicates allow,

Among the many servers, the CentOS server is a leader. with its own advantages, the CentOS server has won the support of many netizens. So how can we ensure the security of the CentOS server? Next, we will provide a good solution to some security issues of the CentOS server.

1. use a firewall to close unnecessary ports. if someone else fails to PING the server, the threat is naturally reduced by more than half.

Methods to prevent ping by others:

1) at the command prompt, 0 indicates yes, and 1 indicates no

echo 1 > /proc/sys/net/ipv4/icmp_ignore_all

2) use a firewall to prohibit (or discard) icmp packets

iptables -A INPUT -p icmp -j DROP

3) do not respond to all ICMP packets, for example:

PING TRACERT 

2. enable the security mode (not recommended for commercial application servers)

# Vi/usr/local/Zend/etc/php. ini (when ZO is not installed, the php. ini file is located at/etc/php. ini). safe_mode = On

3. lock the PHP application directory

# Vi/etc tpd/conf. d irtualhost. confphp_admin_value open_basedir/home/*** (*** is the site directory )!

4. do not grant write permissions to unnecessary directories, that is, 777 permissions. keep the root directory as 711. if you cannot run PHP, change it to 755.

5. shielding PHP unsafe parameters (webshell)

# Vi/usr/local/Zend/etc/php. ini (php. ini file location:/etc/php. ini) disable_functions = system, exec, shell_exec, passthru, popen

The following are my server blocking parameters:

disable_functions = passthru,exec,shell_exec,system,set_time_limit,ini_alter,dl, .pfsockopen,openlog,syslog,readlink,symlink,link,leak,fsockopen,popen,escapeshell ..cmd,error_log .

The above method can easily solve the security problem of the CentOS server.

6. change the SSH port and restrict the IP address used for SSH login

To change the SSH port, you 'd better change it to 10000 or above, and the chances of others scanning the port will also decrease.

vi /etc/ssh/sshd_config

Change PORT to PORT 1000 or above. Create a common logon user and cancel direct root logon.

useradd  'username'passwd 'username'vi /etc/ssh/sshd_config

Add the following sentence at the end:

PermitRootLogin no # cancel root direct remote login

7. change the following file permissions so that no one has the permission to change the account:

chattr +i /etc/passwd chattr +i /etc/shadow chattr +i /etc/group chattr +i /etc/gshadowchmod 600 /etc/xinetd.conf

8. delete unused accounts with a bloated system:

Userdel admuserdel lpuserdel syncuserdel shutdownuserdel haltuserdel newsuserdel too many gamesuserdel too ftp # If you do not allow anonymous FTP, delete this user account groupdel too lpgroupdel newsgroupdel too gamesgroupdel dipgroupdel pppusers

Change the permissions of the following files so that no one has the permission to change the account:

chattr i /etc/passwdchattr i /etc/shadowchattr i /etc/groupchattr i /etc/gshadow

Finally, disable anonymous FTP user login.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.