vaporup / ssh-tools

Making SSH more convenient
GNU General Public License v3.0
889 stars 27 forks source link

wish: print server host keys in several formats #5

Closed stappersg closed 6 years ago

stappersg commented 6 years ago

ssh-hostkeys foo.tld

output

RSA 2048  40:12:ab:be:ef
RSA 2048 Azqerq
ECDSA 256 13:24:ca:fe
ECDSA 256 Rwosw

So check for several hostkeys, print them in various formats.

Use case: Having hostkey in one format and being able to verify with other format upon first connection with SSH-client that shows other format.

vaporup commented 6 years ago

Doesn't ssh-keyscan from OpenSSH do that already?

ssh-keyscan foo.tld

vaporup commented 6 years ago

Or do you mean something like this?

https://unix.stackexchange.com/a/268692

stappersg commented 6 years ago

Currently

$ ssh-keyscan abel.debian.org
# abel.debian.org SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u2
abel.debian.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCokM3vP/p27bNUnfS7kLrGDRUho4E4GOwGQlpLjoLA+eGdLckjiHsul1Fcw8aR9dXzGl7j8QjPvhWO8YsNo+ezCvRmduuCte5L8HNZ08F8Z6ks8BG+VkZKjQ4KXwim8JRnj5t97GtcALWKIXwp5LiXU2H4k9NBlpcaB+/SOHE+cjEv8GhZJ80wHvLnp11JEfrfdeVdZQS/wM7fNIW6UjMsfsxJ1tmmRt0B9JxzdnvLtihXi8HjUeiFRdHDJd1KoaxIMMzKz4UYWBABAdjug39A+jKfMUrI6jTjsQUGZu4zEk3wghaZLBLizs/xE8E/CDIcsqU+Qmx/kZYYDsmZG+nD
$ ssh abel.debian.org
The authenticity of host 'abel.debian.org (217.140.96.56)' can't be established.
RSA key fingerprint is 19:9f:dd:68:7b:e4:cc:7e:c6:54:16:51:a4:da:dc:98.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
$ 

Wish

$ ssh-hostkeys abel.debian.org
# abel.debian.org SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u2
ssh-rsa SIZE HASHNAME  Hash_of_AAAAB3NzaC1yc2EAAA.....mx/kZYYDsmZG+nD
ssh-rsa SIZE  HASHNAME 19:9f:dd:68:7b:e4:cc:7e:c6:54:16:51:a4:da:dc:98.
$ ssh abel.debian.org
The authenticity of host 'abel.debian.org (217.140.96.56)' can't be established.
RSA key fingerprint is 19:9f:dd:68:7b:e4:cc:7e:c6:54:16:51:a4:da:dc:98.
Are you sure you want to continue connecting (yes/no)? yes
  ...
vaporup commented 6 years ago

OK, check out the prototype in MASTER

stappersg commented 6 years ago

Seen the source code. Couldn't understand it completely. (feel free to read / recieve that as "source code feels somewhat awkward" )

And yes, I have tried it

$ wget https://raw.githubusercontent.com/vaporup/ssh-tools/master/ssh-hostkeys
$ chmod a+x ssh-hostkeys 
$ ./ssh-hostkeys abel.debian.org
 (ED25519)         256         MD5  02:cf:ee:c0:42:ff:9a:5a:79:21:93:06:8b:12:7f:cf
 (ED25519)         256      SHA256  1ojC0ehdNMu3GPDUBykHgBtnSgV1f7GmkZTLh5xp++s
     (RSA)        2048         MD5  19:9f:dd:68:7b:e4:cc:7e:c6:54:16:51:a4:da:dc:98
     (RSA)        2048      SHA256  bUw+q8Uho0lv+IqQf7Dg7E2HbF5ixcbBu4Qd+XG60r8
$ 

Thanks Cheers Geert Stappers (now closing this issue)