创建普通用户
#创建用户
useradd xsw
#修改密码
passwd xsw
添加sudo 权限
#加可读权限
chmod +w /etc/sudoers
vim /etc/sudoers
#在文件root下添加普通用户
root ALL=(ALL) ALL
xsw ALL=(ALL) ALL
#保存
chmod -w /etc/sudoers
修改ssh端口
找到SSh服务配置文件路径一般是: /etc/ssh/sshd_config
查找到 Port=22字段,将其前面的注释去掉,:
#Port 22
Port 23456
#ListenAddress 0.0.0.0
#ListenAddress ::
修改保存后,重启SSH服务:
systemctl restart sshd
禁止 Root 用户通过 SSH 登陆
修改 SSH 的配置文件 /etc/ssh/sshd_config,在其中加上 PermitRootLogin no 配置项。
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#重启ssh
systemctl restart sshd
开启防火墙或安全组
只开放你的ssh 端口