EN
Bash - print fingerprints for SSHD keys (md5, sha-1, sha-A256 fingerprints)
9 points
In this short article, we would like to show how using Bash, get a fingerprints for certificates used by SSH server under Debian.
Simple steps:
- login to your server,
- list keys in
/etc/ssh
directory with the following command:xxxxxxxxxx
1ls -al /etc/ssh
Example output:
xxxxxxxxxx
1total 600
2drwxr-xr-x 2 root root 4096 Jun 19 17:22 .
3drwxr-xr-x 79 root root 4096 Sep 15 08:44 ..
4-rw-r--r-- 1 root root 565189 Jan 31 2020 moduli
5-rw-r--r-- 1 root root 1580 Jan 31 2020 ssh_config
6-rw-r--r-- 1 root root 3233 May 29 13:40 sshd_config
7-rw------- 1 root root 1381 May 29 12:05 ssh_host_dsa_key
8-rw-r--r-- 1 root root 607 May 29 12:05 ssh_host_dsa_key.pub
9-rw------- 1 root root 513 May 29 12:05 ssh_host_ecdsa_key
10-rw-r--r-- 1 root root 179 May 29 12:05 ssh_host_ecdsa_key.pub
11-rw------- 1 root root 411 May 29 12:05 ssh_host_ed25519_key
12-rw-r--r-- 1 root root 99 May 29 12:05 ssh_host_ed25519_key.pub
13-rw------- 1 root root 1823 May 29 12:05 ssh_host_rsa_key
14-rw-r--r-- 1 root root 399 May 29 12:05 ssh_host_rsa_key.pub
- select one key and print fingerprints with the following commands:
xxxxxxxxxx
1ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_rsa_key.pub
2ssh-keygen -l -E sha1 -f /etc/ssh/ssh_host_rsa_key.pub
3ssh-keygen -l -E sha256 -f /etc/ssh/ssh_host_rsa_key.pub
Where:
rsa
inssh_host_rsa_key.pub
in the above command can be replaced bydsa
,ecdsa
ored25519
depending on available cryptographic algorithms.Example output:
xxxxxxxxxx
12048 MD5:9a:f3:d8:2a:fa:54:80:46:1b:63:52:7d:2f:37:f8:b5 root@my-server (RSA)
22048 SHA1:X0NYsrgjgSINFEZkWuNOogbImPP root@my-server (RSA)
32048 SHA256:iJcZp8p1XlTJFpsQfDb5fEwGzt2vPsshm43hi+tQU2V root@my-server (RSA)
Hint: in the presented results,
/etc/ssh/ssh_host_rsa_key.pub
file contained only one key.