“ key_load_public:没有这样的文件或目录”是什么意思?


42

我一直在排除PubkeyAuthentication-only问题。当我使用详细模式时,会看到很多“ key_load_public:没有这样的文件或目录”

显然,密钥存在于文件系统上,因此该消息似乎没有惯常含义:

$ ls -al ~/.ssh/id_*
-rw-------  1 jwalton  staff   751 Feb  4  2013 id_dsa
-rw-------  1 jwalton  staff   608 Feb 18  2015 id_dsa.pub
-rw-------  1 jwalton  staff   314 Feb  4  2013 id_ecdsa
-rw-------  1 jwalton  staff   180 Feb 18  2015 id_ecdsa.pub
-rw-------  1 jwalton  staff   464 Aug 23 18:15 id_ed25519
-rw-------  1 jwalton  staff   103 Aug 23 18:15 id_ed25519.pub
-rw-------  1 jwalton  staff  2546 Feb  4  2013 id_rsa
-rw-------  1 jwalton  staff   572 Feb 18  2015 id_rsa.pub

确切地说,“ key_load_public:没有这样的文件或目录”是什么意思?


我的.ssh/config文件有:

$ cat ~/.ssh/config
IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_ecdsa
IdentityFile ~/.ssh/id_dsa
IdentityFile ~/.ssh/id_rsa

添加*.pub扩展名无效。我尝试使用和不使用这两种方法,*.pub因为手册页对于需要指定的密钥(公共密钥或私有密钥)含糊不清。(公共密钥是标识所需要的全部;需要私钥来证明在质询/响应中密钥的所有权):

IdentityFile
    Specifies a file from which the user's DSA, ECDSA or DSA authen-
    tication identity is read...

$ ssh -v -p 1522 jwalton@192.168.1.11
OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /Users/jwalton/.ssh/config
debug1: Reading configuration data /usr/local/etc/ssh_config
debug1: Connecting to 192.168.1.11 [192.168.1.11] port 1522.
debug1: Connection established.
debug1: identity file /Users/jwalton/.ssh/id_ed25519.pub type 4
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jwalton/.ssh/id_ed25519.pub-cert type -1
debug1: identity file /Users/jwalton/.ssh/id_ecdsa.pub type 3
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jwalton/.ssh/id_ecdsa.pub-cert type -1
debug1: identity file /Users/jwalton/.ssh/id_dsa.pub type 2
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jwalton/.ssh/id_dsa.pub-cert type -1
debug1: identity file /Users/jwalton/.ssh/id_rsa.pub type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/jwalton/.ssh/id_rsa.pub-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
...

Answers:


66

它的字面意思是:没有ssh要访问的文件或目录。

然而,它谈论中提到的文件下面,上面没有。您只有常规的公共密钥,但没有它们的SSH 证书(大概是因为您不需要它们)。但是,OpenSSH将始终尝试.pub-cert为每个身份密钥加载关联的文件。


如果您有兴趣,ssh-keygen(1)手册讨论有关创建OpenSSH证书颁发机构和签署证书的问题。(注意:这不使用X.509,仅使用OpenSSH自己的证书格式。)

通常,仅当您拥有大量用户(和/或服务器)但不想使用Kerberos时,证书才有用。


谢谢Grawity。对于IdentityFile,我应该指定什么?公钥还是私钥?
jww

它应该是私钥文件(实际上包含整个密钥对-额外的.pub文件仅出于[方便]的目的)。
grawity

5
Ooph,这令人困惑。有人应该真正提交错误报告:-(
einpoklum-恢复Monica 2015年

1
如果“提交错误报告”是指“提交修复程序”,请随时这样做:github.com/openssh/openssh-portable/blob/master/README#L38 :)。这是一个开始寻找的地方:github.com/openssh/openssh-portable/blob/master/key.c#L342github.com/openssh/openssh-portable/blob/master/ssh.c#L2091
亚历山大·伯德

12
有时,“错误报告”字面意思是“错误报告”。并非每个openssh用户都是C程序员。
grawity
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.