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

What is the SHA256 that comes on the sshd entry in auth.log?

· 52CE 我爱测

When logging in via ssh, it can be seen the following on auth.log: Dec 14 16:29:30 app sshd[22781]: Accepted publickey for dev from XXX.XXX.XX.XXX port XXXXX ssh2: RSA SHA256:pO8i... I've been trying to figure out what is this SH…

问题原文

原帖链接 · Márcio Jales · CC BY-SA 3.0

When logging in via ssh, it can be seen the following on auth.log:

Dec 14 16:29:30 app sshd[22781]: Accepted publickey for dev from XXX.XXX.XX.XXX port XXXXX ssh2: RSA SHA256:pO8i...

I've been trying to figure out what is this SHA256 information, but I couldn't find anything that seems to match. First I thought it could be some information from the client (public key, fingerprint, hashed hostname etc) I'm connecting from, but I didn't find anything to confirm, neither at the server side.

The closest information I've found is here, but I didn't understand when it says "And here is an example using a key for authentication. It shows the kewy (a misspelling, probably) fingerprint as a SHA256 hash in base64.", since I haven't found a corresponding key fingerprint of any kind.

Thank you.

已采纳解答

原帖链接 · Joshua Griffiths · CC BY-SA 4.0

This is the SHA256 hash for the RSA public key which was used to authenticate the SSH session.

This is how to verify it:

ssh-keygen -lf .ssh/id_rsa.pub

Or, to verify without ssh-keygen:

  • Remove the ssh-rsa prefix
  • Decode the key to bytes using base64
  • Get the SHA256 hash for the key (as bytes, not hex)
  • Encode the bytes using base64

For example:

cat .ssh/id_rsa.pub    |
    awk '{ print $2 }' | # Only the actual key data without prefix or comments
    base64 -d          | # decode as base64
    sha256sum          | # SHA256 hash (returns hex)
    awk '{ print $1 }' | # only the hex data
    xxd -r -p          | # hex to bytes
    base64               # encode as base64

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

资料来源与适用范围

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

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

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