登陆方式:
- 修改配置文件/etc/ssh/sshd_config ,将"PasswordAuthentication yes"修改
为"PasswordAuthentication no" - 重启ssh服务
- 生成密钥
在服务器端输入命令:
[root@localhost~]# ssh-keygen -t rsa - 将/root/.ssh/id_rsa.pub改名为/root/.ssh/authorized_keys :
[root@localhost~]mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys - 将私钥id_rsa拷贝到客户机/root/.ssh/中
- 登陆报错
[root@localhost ~]# ssh 172.30.202.150
Authorized users only. All activities may be monitored and reported.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/root/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/root/.ssh/id_rsa": bad permissions
root@172.30.202.150: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
解决方法
直接chmod权限0600