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

How can I confirm SSH fingerprint when connecting to a new Amazon EC2 instance using PuTTY?

· 52CE 我爱测

When I create a new EC2 instance running Ubuntu 18.04, using a new EC2-generated keypair, I convert the resulting .pem to .ppk using puttygen, then try to connect to the instance using PuTTY, and I am shown the expected prompt to…

问题原文

原帖链接 · Max Barraclough · CC BY-SA 4.0

When I create a new EC2 instance running Ubuntu 18.04, using a new EC2-generated keypair, I convert the resulting .pem to .ppk using puttygen, then try to connect to the instance using PuTTY, and I am shown the expected prompt to confirm the SSH fingerprint:

PuTTY shows me a hex representation of an MD5 hash. This is the only fingerprint format PuTTY supports.

Outside PuTTY, the preferred fingerprint format these days is a SHA256 hash represented in Base64.

If I look in the EC2 system log of the freshly-created instance, sure enough I see the SSH fingerprints, SHA256 in Base64 representation:

Looking at this answer, Amazon Linux used to (perhaps still does?) output a hash in hex, rather than Base64.

How can I verify that the Base64 SHA256 fingerprint shown in the EC2 system log, matches up with what PuTTY is connecting to? I would rather avoid installing EC2-specific tooling.

Incidentally, I had no trouble confirming the fingerprint when using OpenSSH from PowerShell. (I would consider using this rather than PuTTY, but it seems to lack mouse support.)

Also, I found this answer informative, but it doesn't give me an answer.

(All details shown in screenshots reflect a short-lived instance. I have destroyed the keypair.)

已采纳解答

原帖链接 · dave_thompson_085 · CC BY-SA 4.0

Accept (at least temporarily) the host key, after noting the key type (algorithm) and optionally fingerprint, but do not yet enter any sensitive information like your password(s) or cat video(s). Do

ssh-keygen -l -f /etc/ssh/ssh_host_{type}_key.pub

This will show the 'modern' (sha256/base64) fingerprint for the key. Check it matches the value in the AWS console. You can add -v and instead check the 'ASCII art' drawing, which research reportedly says is easier to compare, although personally I haven't found it so. But then I was never good at those "what's wrong in this drawing" puzzles that used to be in the newspapers, when there used to be newspapers.

Optionally also do

ssh-keygen -l -E md5 -f {same}

to confirm the 'ancient' (md5/hex) fingerprint matches the value shown by PuTTY, although there should be little doubt of that.

If this turns out to be the wrong host, disconnect and delete the wrongly-accepted key from the registry in HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys .

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

资料来源与适用范围

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

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

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