禁用root账号登录
创建新的用户
创建一个test用户useradd test
设置密码passwd test设置test用户密码
此时test用户已经可以通过ssh登录禁用
root用户登录
修改vi /etc/ssh/sshd_config中的PermitRootLogin yes为PermitRootLogin no(如果没有请添加)重启
sshd
systemctl restart sshd或systemctl restart sshd.service, 此时root账号已经无法登录
配置test用户成sudo用户(如果不需要sudo用户无需配置)
- 使用
root配置sudo用户
如果当前不是root登录, 请使用su root登录root账号 - 增加
sudo用户
使用vi /etc/sudoers打开文件
在root ALL=(ALL) ALL下增加test ALL=(ALL) ALL保存即可
如果文件编辑没有权限使用chmod u+w /etc/sudoers增加写入权限修改后使用chmod u-w /etc/sudoers去掉权限