1、添加普通用户,经过sudo受权管理node
useradd [用户名] 填加用户命令linux
passwd [用户名] 填加用户密码 添加密码的时候必定要指定用户名,不然就是修改当前用户密码安全
修改格式以下:用户 用户机器=(受权那个角色的权限) 受权的东西服务器
可是在普通用户执行命令时得在命令前加sudo 例子:sudo useradd 666网络
查看所在用户有的权限:sudo -lssh
受权目的:即能让小白干活,又不能威胁系统安全。优化
2、更改默认的SSH服务器端口及禁止root用户远程链接加密
[root@localhost ~]# ls -l /etc/ssh/sshd_config -rw-------. 1 root root 3879 Oct 15 2014 /etc/ssh/sshd_config
[root@localhost ~]# cd /etc/ssh
[root@localhost ssh]# cp sshd_config sshd_config.ori
[root@localhost ssh]# vi sshd_config
Port 52113 ##ssh端口谁都知道是22,得改了##
PermitEmptyPasswords no ##禁止空密码登录##
PermitRootLogin no ##root用户都知道,禁止他远程登录,用的时候切进去 su -##
UseDns no ##不适用DNS##
[root@localhost ssh]# /etc/init.d/sshd reload
Reloading sshd: [ OK ]
[root@localhost ssh]# /etc/init.d/sshd reload/
3、定时更新服务器时间spa
[root@localhost ~]# /usr/sbin/ntpdate time.nist.gov
[root@localhost ~]# echo '*/5* * * * /uer/sbin/ntpdate time.nist.gov > /dev/null 2>&1' >>/var/spool/cron/root
4、配置yum更新源,从国内更新下载安装rpm包code
[root@localhost ~]#cd /etc/yum.repos.d/
[root@localhost ~]yum.repos.d]#
[root@localhost ~]#yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak
[root@localhost ~yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
[root@localhost ~yum.repos.d]# cp CentOS6-Base-163.repo CentOS-Base.repo
5 cp: overwrite `CentOS-Base.repo'? y
[root@localhost ~yum.repos.d]#
5、关闭selinux及iptables
[root@localhost ~]# cat /etc/selinux/config [root@localhost ~]# vi /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled ##改这个原来是:enforcing## # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
[root@localhost ~]# grep "disable" /etc/selinux/config
[root@localhost ~]# setenforce 0 ##临时关闭防火墙##
[root@localhost ~]#/etc/init.d/iptables stop
[root@localhost ~ yum.repos.d]# getenforce ##查看selinux当前状态##
Permissive
6、调整文件描述符的数量
ulimit -HSn 65535 ##临时加大##
echo '* - nofile 65535 '>>/etc/security/limits.conf##永久加大##
7、清理/var/spool/clientmquene/目录垃圾文件,防止inodes节点被沾满
[root@localhost /]#find /var/spool/clientmquene/ -type f |xargs rm -f
8、精简开机自启动服务(crond,sshd,network,syslog(rsysloy))
[root@localhost ~]# chkconfig
[root@localhost ~]#for lcr in `chkconfig --list | grep "3:on" | awk '{print $1}'`;do chkconfig $lcr off;done
[root@localhost ~]#for lcr in crond sshd network rsyslog;do chkconfig $lcr on;done
9、linux内核参数优化/etc/sysct.conf,而后sysctl -p生效
服务器内核优化:
[root@localhost /]# vi /etc/sysctl.conf
对网络ipv4的优化:把图片里的内容放到/etc/sysctl.conf下面
对防火墙优化:作法同上
10、更改字符集,支持中文,但建议仍是用英文字符集,防止乱码问题
[root@localhost sysconfig]# vi /etc/sysconfig/i18n #LANG="en_US.UTF-8" LANG="zh_CN.GB18030" SYSFONT="latarcyrheb-sun16"
11、锁定关键系统文件。