ssh 教程
ssh 通过密钥登录
编辑 ~/.ssh/config
文件添加配置
Host test01
HostName xx.xx.xx.xx
ForwardAgent yes
User root
ssh-copy-id
上传密钥到服务器
# ssh-copy-id Host
ssh-copy-id test01
ssh-copy-id -i ~/.ssh/xxx test01
登录上之后编辑服务器ssh 配置文件,禁用密码登录。编辑/etc/ssh/sshd_config
PasswordAuthentication no
PermitEmptyPasswords no
PermitRootLogin yes
PubKeyAuthentication yes
RSAAuthentication yes
重启一下 sshd
sudo systemctl restart sshd.service
sudo systemctl enable sshd.service
新增用户,并添加到sudo 组
adduser xxxx # 推荐全部小写
usermod -aG sudo xxx # 添加到 sudo 组