禁止Root远程登录
先新增普通用户
useradd www123
passwd www123
备份 sshd配置文件 /etc/ssh/sshd_config
cp /etc/ssh/sshd_config /etc/ssh/sshd_config_original
vim /etc/ssh/sshd_config 在文件最后添加如下几行,然后退出保存
Port 2222 ##这个端口主是以后你自已的ssh连接端口,默认是22
UseDNS no
AddressFamily inet
PermitRootLogin no
SyslogFacility AUTHPRIV
PasswordAuthentication yes
ChallengeResponseAuthentication yes
免密码切换root用户
/etc/sudoers
直接用visudo命令即可编辑,语法错误奖无法保存!!!
root ALL=(ALL) ALL
www123 ALL=(ALL) NOPASSWD: ALL
visudo -c 检查 语法
切换到root
sudo su -