ssh用私钥登录远程服务器时提示私钥不安全问题解决

ssh用私钥ding_test.pem登陆服务器11.10.37.54

root@test-ubuntu:~# ssh -i ding_test.pem [email protected]
The authenticity of host '11.10.37.54 (11.10.37.54)' can't be established.
ECDSA key fingerprint is SHA256:FFPaPnDwHqIU2Kp1m46lgTRxaCPf4H5xKyRH8eJNMVc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '11.10.37.54' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'ding_test.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "ding_test.pem": bad permissions
Permission denied (publickey).

出现如上错误。

解决方法为 chmod 600

root@test-ubuntu:~# chmod 600 ding_test.pem 
root@test-ubuntu:~# ssh -i ding_test.pem ubuntu@11.10.37.54
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-43-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

ubuntu@test-ubuntu2:~$ 

ssh远程登陆成功!

你可能感兴趣的:(linux)