Akemi

Linux环境初始化

2024/06/28

云厂商Linux基础优化

sshd策略(安全)
Port 22222 修改默认端口为1w以上的端口
UseDNS no 关闭dns反查
GSSAPIAuthentication no 关闭GSSAPI验证
PermitRootLogin no 禁止root账号登录
安全配置
关闭selinux
设置安全组
安装yum源
安装epel源,repoforge源
升级update
时间同步
公用时间服务器更新
使用ntpdate(计划任务):/usr/sbin/ntpdate ntp1.aliyun.com >> /var/log/ntp.log 2>&1;/sbin/hwclock -w
使用chronyd:修改/etc/chrony.conf
重要文件加锁
chattr+i /etc/sudoers chattr+i /etc/shadow
chattr+i /etc/passwd chattr+i /etc/grub.conf
系统资源优化
/etc/security/limits.conf

1
2
3
4
5
6
* soft nproc 20480 # 用户最大进程数
* hard nproc 20480
* soft nofile 655360 # 最大打开文件数
* hard nofile 655360
* soft memlock unlimited # 内存限制
* hard memlock unlimited

操作系统安全
1.更新系统软件
yum update gilbc openssl
2.禁ping
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
3.设置tcp_wrappers防火墙(和iptables差不多)
例:只允许192.168.10.254进行sshd的访问
ehco "sshd:192.168.10.254" >>/etc/hosts.allow echo “sshd:ALL” >> /etc/hosts.deny
4.配置iptables,详情可见另一篇博客

CATALOG
  1. 1. 云厂商Linux基础优化