大网数据广告活动
服务器运维问答

Why can't curl retrieve the SSH host key (key: <none>)

· 52CE 我爱测

I've been using curl (by means of git-ftp) for a while, and passing only username and an sftp URL. Authentication would always work implicitely through publickey. Suddenly curl will not connect through SSH anymore – apparently be…

问题原文

原帖链接 · Andy · CC BY-SA 3.0

I've been using curl (by means of git-ftp) for a while, and passing only username and an sftp URL.

Authentication would always work implicitely through publickey.

Suddenly curl will not connect through SSH anymore – apparently because it does not get a host key and therefore rejects the connection:

Trying {IP}... * Connected to host.example.com ({IP}) port 22 (#0) * SSH MD5 fingerprint: {Fingerprint} * SSH host check: 2, key: <none> * Closing connection 0

Why can't curl get the key?

Connections with ssh -v work and do give me 2 host keys, also curl --insecure will work.

已采纳解答

原帖链接 · Andy · CC BY-SA 3.0

libssh2 does not support some later keys like ecdsa-sha2-nistp256 and ssh-ed25519.

So if you already have one of these keys in your .ssh/known_hosts, libssh2 will fail. But you can add another key that libssh2 supports, like RSA:

To fix it, retrieve the RSA public key from the remote host and add it to your known_hosts file:

ssh-keyscan hostname.example.com >> ~/.ssh/known_hosts

The exact format and file location might vary by system.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-06-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。