ssh -i 密钥文件无法登陆问题

Posted cloud-datacenter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssh -i 密钥文件无法登陆问题相关的知识,希望对你有一定的参考价值。

一、用ssh 带密钥文件登录时候,发生以下报错
 [root@99cloud1 ~]# ssh -i hz-keypair-demo.pem centos@172.16.17.104
The authenticity of host ‘172.16.17.104 (172.16.17.104)‘ can‘t be established.
ECDSA key fingerprint is SHA256:HXYEa2IVBhTJ1AO+GDvROEvHM5ZRLgKxXsSaFmc6CNc.
ECDSA key fingerprint is MD5:cd:dd:3f:dd:66:91:30:4c:0e:e5:a2:35:45:c2:23:41.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘172.16.17.104‘ (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for ‘hz-keypair-demo.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 "hz-keypair-demo.pem": bad permissions
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
二、修改密钥文件权限

[root@99cloud1 ~]# chmod 600 hz-keypair-demo.pem
[root@99cloud1 ~]# ip netns exec qdhcp-c2bc63d3-6ab2-4862-96f0-1a6d91df92f8 ssh -i hz-keypair-demo.pem centos@172.16.17.104

三、正常登录

[root@99cloud1 ~]# ssh -i hz-keypair-demo.pem centos@172.16.17.104
[centos@centos0130 ~]$ ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc pfifo_fast state UP group default qlen 1000
    link/ether fa:16:3e:fe:22:71 brd ff:ff:ff:ff:ff:ff
    inet 172.16.17.104/24 brd 172.16.17.255 scope global dynamic eth0
       valid_lft 85543sec preferred_lft 85543sec
    inet6 fe80::f816:3eff:fefe:2271/64 scope link
       valid_lft forever preferred_lft forever

以上是关于ssh -i 密钥文件无法登陆问题的主要内容,如果未能解决你的问题,请参考以下文章

SSH详解-3.密钥登陆

ssh无法免密登陆

Hapoop 搭建 设置虚拟机SSH无密钥登陆

linux服务器关机重启后,无法远程ssh登陆问题记录

远程登陆与远程密钥登陆

SSH2 登陆 LOCALHOST 为啥无法登陆?其它机器可以连接