密钥登录
mkdir -p /root/.ssh
chmod 700 /root/.ssh
vim /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
mkdir -p .ssh
chmod 700 .ssh
sudo cat /root/.ssh/authorized_keys > .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
- 修改配置文件: /etc/ssh/sshd_config
RSAAuthentication yes # 开启密钥登入的认证方式
PubkeyAuthentication yes # 开启密钥登入的认证方式
PermitRootLogin yes #此处请留意 root 用户能否通过 SSH 登录,默认为yes:
PasswordAuthentication yes #当我们完成全部设置并以密钥方式登录成功后,可以禁用密码登录。这里我们先不禁用,
$ sudo service sshd restart
$ sudo systemctl restart sshd