怎么学做淘宝电商网站,太原学网站开发的学校,青岛商家都上什么网站,甘肃网站建设企业推荐1. 批量安装部署
2. 初始化配置
3. 禁用Selinux
永久更改 SELinux 配置#xff1a; 编辑 SELinux 配置文件#xff1a;使用文本编辑器打开 /etc/selinux/config 文件#xff1a; 在配置文件中#xff0c;找到 SELINUX… 的行。将其值更改为以下选项之一#xff1a; e…1. 批量安装部署
2. 初始化配置
3. 禁用Selinux
永久更改 SELinux 配置 编辑 SELinux 配置文件使用文本编辑器打开 /etc/selinux/config 文件 在配置文件中找到 SELINUX… 的行。将其值更改为以下选项之一 enforcing启用 SELinux 并强制执行安全策略。permissive启用 SELinux 但仅记录违反安全策略的操作不会阻止它们。disabled禁用 SELinux。4. 配置YUM源/仓库
vim /etc/yum.repos.d/myrepo.repo
[myrepo]
nameMy YUM Repository
baseurlhttp://example.com/yum/repo/ # 源的 URL
enabled1 # 设置为 1 启用源设置为 0 禁用源
gpgcheck1 # 设置为 1 执行 GPG 检查设置为 0 不执行检查
gpgkeyhttp://example.com/yum/RPM-GPG-KEY # GPG 密钥的 URL5. 下载安装常用工具包和软件包
[rootlocalhost ~]# yum -y install vim //vim文本编辑器
[rootlocalhost ~]# yum -y install bash-completion //tab键的软件包重新登陆才生效
[rootlocalhost ~]# yum -y install net-tools //安装网络相关联的软件包ifconfig
[rootlocalhost ~]# yum -y install zip.x86_64 //压缩zip包的软件
[rootlocalhost ~]# yum -y install unzip.x86_64 //解压zip包的软件
[rootlocalhost ~]# yum -y install gcc make //安装编译工具6. SSH登录/用户设置
###登录设置
[rootlocalhost ~]# vim /etc/ssh/sshd_config
......
UseDNS no //将注释去除并将UseDNS的值设置为no
......###用户设置
[rootlocalhost ~]# vim /etc/ssh/sshd_config
......
在文件的末尾添加新行,如果你想允许用户alice和bob登录将选项设置为 AllowUsers alice bob
[rootlocalhost ~]# systemctl restart sshd //重新启动SSH服务以使更改生效7. 注册新用户和删除不必要的用户/组
[rootlocalhost ~]# cp /etc/passwd /etc/passwdbai #先备份
[rootlocalhost ~]# vim /etc/passwd #编辑用户在前面加#注释掉
......
#adm:x:3:4:adm:/var/adm:/sbin/nologin
#lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
#sync:x:5:0:sync:/sbin:/bin/sync
#shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
#halt:x:7:0:halt:/sbin:/sbin/halt
#mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
#operator:x:11:0:operator:/root:/sbin/nologin
#games:x:12:100:games:/usr/games:/sbin/nologin
#ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin #注释ftp匿名账户
......
[rootlocalhost ~]# cp /etc/group /etc/groupbai #先备份
[rootlocalhost ~]# vim /etc/group #编辑用户组在前面加#注释掉
......
#adm:x:4:adm
#lp:x:7:Ip
#uucp:x:14:uucp
#games:x:20:
#dip:x:40:
......8. 关闭不必要的项目服务
service acpid stop chkconfig acpid off
#停止服务取消开机层动 #电源进阶设定常用在Laptop 上
service autofs stop chkconfig autofs off
#停用自动挂载档按系统与调边装署
service bluetooth stop chkconfig bluetooth off
#停用luetooth蓝芽
service cpuspeed stop chkconfig cpuspeed of
#停用控制CPU速度主要用来省电
service cups stop chkconfig cups off
#停用 Common UNIX Printing System 使采统支援印表机
service ip6tables stop chkconfig ip6tables off
#禁止IPv6
如果要恢复某一个服务可以执行下面操作
service acpid start chkconfig acpid on## 禁止非root用户执行/etc/rc.d/init.d/下的采统命禁止非root用户执行/etc/rc.d/init.d/下的系统命合
chmod -R 700 /etc/rc.d/init.d/*
Chmod -R 777 /etc/rc.d/init.d/*
#恢复默认设遇9. 限制/设置不同文件的权限
chattr a .bash_history#避免删除bash_history或者重定向到/dev/null
chattr i bash_history
chmod 700 /usr/bin 恢复chmod 555 /usr/bin
chmod 700 /bin/ping 恢复 chmod 4755 /bin/ping
chmod 700 /usr/bin/vim 恢复 chmod 755 /usr/bin/vim
chmod 700 /bin/netstat 恢复 chmod 755 /bin/netstat
chmod 700 /usr/bin/tail 恢复 chmod 755 /usr/bin/tail
chmod 700 /usr/bin/less 恢复 chmod 755 /usr/bin/less
chmod 700 /usr/bin/head 恢复 chmod 755 /usr/bin/head
chmod 700 /bin/cat 恢复 chmod 755 /bin/cat
chmod 700 /bin/uname 恢复 chmod 755 /bin/uname
chmod 500 /bin/ps 恢复 chmod 755 /bin/ps10. 给对应文件增加不可更改属性
chattr i /etc/passwd
chattr i /etc/shadow
chattr i /etc/group
chattr i /etc/gshadow
chattr i /etc/services #给系统服务端口列表文件加锁防止未经许可的删除或添加服务
lsattr /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/services #显示文件的属性
注意:执行以上权限修改之后就无法添加删除用户了。
如果再要添加删除用户需要先取消上面的设置等用户添加删除完成之后再执行上面的操作
chattr -i /etc/passwd #取消权限锁定设置
chattr -i /etc/shadow
chattr -1 /etc/group
chattr -i /etc/gshadow
chattr -i /etc/services #取消系统服务端口列表文件加锁
现在可以进行添加删除用户了操作完之后再锁走目录文件11. 修改history命令属性
cp /etc/profile /etc/profilebak
vim /etc/profile
找到 HISTSIZE1000 改为 HISTSIZE10012. 隐藏服务器系统信息
在缺省情况下当你登陆到linux系统它会告诉你该linux发行版的名称、版本、内核版本、服务器的名称。 为了不让这些默认的信息泄露出来我们要进行下面的操作让它只显示一个login:提示符。 删除/etc/issue和/etc/issue.net这两个文件或者把这2个文件改名效果是一样的。
mv /etc/issue /etc/issuebak
mv /etc/issue.net /etc/issue.netbak13. 优化内核参数
[rootlocalhost ~]# cp /etc/sysctl.conf /etc/sysctl.confbak #先备份
[rootlocalhost ~]# vim /etc/sysctl.conf #在文件末尾添加以下几行
net.ipv4.tcp_max_syn_backlog 65536
net.core.netdev_max_backlog 32768
net.core.somaxconn 32768
net.core.wmem_default 8388608
net.core.rmem_default 8388608
net.core.rmem_max 16777216
net.core.wmem max 16777216
net.ipv4.tcp_timestamps 0
net.ipv4.tcp_synack_retries 2
net.ipv4.tcp_syn_retries 2
net.ipv4.tcp_tw_recycle 1
#net.ipv4.tcp_tw len 1
net.ipv4.tcp_tw_reuse 1
net.ipv4.tcp_mem 94500000 915000000 927000000
net.ipv4.tcp_max_orphans 3276800
#net.ipv4.tcp_fin_timeout 30
#net.ipv4.tcp_keepalive_time 120
net.ipv4.ip_local_port_range 10024 65535
#(表示用于向外连接的端口范围。缺省情况下很小32768到61000 注意这里不要将是低值设的太低否则可能会占用掉正常的端口
[rootlocalhost ~]# /sbin/sysctl -p #使配置立即生效14. 系统优化
[rootlocalhost ~]# cp /etc/profile /etc/profilebak2
[rootlocalhost ~]# vim /etc/profile #在文件未尾添加以下内容
ulimit -c unlimited
ulimit -s unlimited
ulimit -SHn 65535
[rootlocalhost ~]# source /etc/profile #使配置立即生效
[rootlocalhost ~]# ulimit -a #显示当前的各种用户进程限制15. 服务器禁止Ping
[rootlocalhost ~]# cp /etc/rc.d/rc.local /etc/rc.d/rc.localbak
[rootlocalhost ~]# vim /etc/rc.d/rc.local #在文件末尾增加下面这一行
[rootlocalhost ~]# echo 1 /proc/sys/net/ipv4/icmp_echo_ignore_all
参数0表示允许 1表示禁止