linux服务器安全优化:禁用root 使用子账户远程登录
# 创建一个普通用户xyz
useradd xyz
# 设置用户xyz的密码
passwd xyz
然后输入新密码,按回车键即可
# 进入SSH配置文件,
vi /etc/ssh/sshd_config
修改 PermitRootLogin yes 为 PermitRootLogin no,取消前面的注释,禁止root用户远程登录;
修改 PermitEmptyPasswords yes 为 PermitEmptyPasswords no,取消前面的注释,禁止空密码用户远程登录。
(可选)修改 Port 22 为 Port 2222,取消前面的注释。(端口号可自定义)
修改端口后,别忘记在防火墙配置里面增加上更改的端口。
然后 :wq 保存退出
# 重启SSH服务生效
service sshd restart