我對 RSA 指紋的理解是,它基本上是一個金鑰的雜湊值。
我對轉發連接埠的理解是以下部分man ssh
:
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to
be forwarded to the given host and port on the local side. This
works by allocating a socket to listen to port on the remote
side, and whenever a connection is made to this port, the connec‐
tion is forwarded over the secure channel, and a connection is
made to host port hostport from the local machine.
當使用 ssh 連接到轉送連接埠時,RSA 金鑰指紋的雜湊值是什麼? 在多台機器上使用相同的 RSA 驗證金鑰將描述我為什麼要問。
或者舉個例子,下面的兩個指紋到底是什麼?
- RSA 金鑰指紋為 94:21:d2:fc:70:2d:8d:bb:71:30:0f:4d:52:49:01:43。
- RSA 金鑰指紋為 b2:5b:19:25:91:50:3c:45:73:c7:7e:4f:da:c3:f6:f3。
取得第一個指紋
機器1
sshtunnel@pi_one:~ $ ssh -R 2222:localhost:22 [email protected]
普通機
[sshtunnel@devserver ~]$ ssh -p 2222 sshtunnel@localhost
The authenticity of host '[localhost]:2222 ([::1]:2222)' can't be established.
RSA key fingerprint is 94:21:d2:fc:70:2d:8d:bb:71:30:0f:4d:52:49:01:43.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
取得第二個指紋
機器2
sshtunnel@pi_two:~ $ ssh -R 2222:localhost:22 [email protected]
普通機
[sshtunnel@devserver ~]$ ssh -p 2222 sshtunnel@localhost
The authenticity of host '[localhost]:2222 ([::1]:2222)' can't be established.
RSA key fingerprint is b2:5b:19:25:91:50:3c:45:73:c7:7e:4f:da:c3:f6:f3.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
[sshtunnel@devserver ~]$
答案1
主機的公鑰位於/etc/ssh/ssh_host_*_key.pub
:
$ ssh localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is 60:6e:7a:10:85:a4:14:f1:37:44:88:17:29:67:b1:e1.
Are you sure you want to continue connecting (yes/no)? ^C
$ ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key
256 60:6e:7a:10:85:a4:14:f1:37:44:88:17:29:67:b1:e1 /etc/ssh/ssh_host_ecdsa_key.pub (ECDSA)
ssh-keygen
(請注意,如果您要求私鑰的指紋(不含副檔名) ,它並不重要.pub
,它會自動讀取相應的公鑰。)
在您的情況下,它是提到的 RSA 金鑰,因此/etc/ssh/ssh_host_rsa_key.pub
,透過連接埠轉發,它是ssh
最終連接到的主機。
對於較新版本的ssh-keygen
,預設輸出是金鑰的 base64 編碼的 SHA256 雜湊值。新增此-E md5
選項會給出十六進位編碼的 MD5 雜湊值(但請注意,現在有一個指示雜湊類型的前綴):
$ ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
256 SHA256:4+dfNAIjGq72HL9UeNEpne8J54yj/4wFpi+/4Bv7dhQ root@... (ECDSA)
$ ssh-keygen -Emd5 -l -f /etc/ssh/ssh_host_ecdsa_key.pub
256 MD5:3c:18:e7:9c:ee:e8:6a:38:7d:74:ef:2f:a5:51:ee:1a root@... (ECDSA)