Linux ssh 安全设置
in 运维 with 0 comment
Linux ssh 安全设置,Linux默认的SSH端口是22,为了安全性就需要修改掉默认的SSH端口号,防止被穷举密码。禁止root登录,新建普通用户登录。

修改SSH默认端口

编辑/etc/ssh/sshd_config 文件

vim /etc/ssh/sshd_config

找到Port 22 改成Port 10086

# 重启ssh
/etc/init.d/ssh restart
# 添加防火墙,放行 10086端口
iptables -A INPUT -p tcp --dport 10086 -j ACCEPT

禁止root登录

禁止root登陆,新建普通用户,登陆后用su -命令转到root用户。

新建用户可参考https://www.hanyibo.com/linux/linux-user-group.html这篇文章

useradd username #新建用户
passwd username #设置密码
sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config #设置禁止root登陆
/etc/init.d/ssh restart #重启SSH

一般设置这些就够了,也可以设置更强的密钥登陆。

Responses