系统版本: Ubuntu 20.04.1 LTS
# 添加新用户
adduser worker
#添加sudo权限
chmod u+d worker /etc/sudoers
vi /etc/sudoers
worker ALL=(ALL:ALL)ALL
# 查看当前用户
whoami
#修改当前用户密码
sudo passwd
# 禁用 root用户登录
vim /etc/ssh/sshd_config
PermitRootLogin no
service sshd restart
# ssh免密码登录 将公钥放置服务器
touch ~/.ssh/authorized_keys
# 关闭密码登录功能
vi /etc/ssh/sshd_config
# 配置为no
PasswordAuthentication no
service sshd restart
Mac 配置SSH 后 仍需要输入密码解决办法
#原因是未将 ~/.ssh/id_rsa添加至钥匙串的管理
ssh-add -K ~/.ssh/id_rsa