Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to compute the MD5 and SHA-1 fingerprints of an RSA key in a Linux server?

1,164 views
Skip to first unread message

Ramon F Herrera

unread,
Apr 27, 2013, 8:19:29 PM4/27/13
to

[Newbie alert!]

I have tried this:

% cd /etc/ssh
% md5sum ssh_host_rsa_key.pub
% sha1sum ssh_host_rsa_key.pub

The file contains 2 equal signs ('='), plus one space and a newline at
the end. I tried removing them but the 2 sums still look incorrect.

Perhaps I need to compute those sums on a binary as opposed to an
ASCII file?

TIA,

-RFH

Bit Twister

unread,
Apr 27, 2013, 9:45:14 PM4/27/13
to
On Sat, 27 Apr 2013 17:19:29 -0700 (PDT), Ramon F Herrera wrote:

> Perhaps I need to compute those sums on a binary as opposed to an
> ASCII file?

OR, use ssh-keygen to do whatever it is you are wanting to do.
You might try doing a
man ssh-keygen

Ramon F. Herrera

unread,
Apr 28, 2013, 1:53:19 PM4/28/13
to
Eureka!! I found the solution!!

% cp /etc/ssh/ssh_host_rsa_key.pub actual-key.b64

Next, edit the 'actual-key.b64' file and remove the first characters
("ssh-rsa ").

% base64 -d -i actual-key.b64 > actual-key.bin

% md5sum actual-key.bin
% sha1sum actual-key.bin

The output of those commands nicely match the expected fingerprints:

http://patriot.net/~ramon/misc/SSH+RSA_Authentication.png

-Ramon

ps: Thanks, Bit Twister for your suggestion, but I was trying to
figure out the internals.

Ivan Shmakov

unread,
Apr 29, 2013, 2:03:58 PM4/29/13
to
>>>>> Ramon F Herrera <gopo...@jonjay.com> writes:

[Cross-posting to news:comp.unix.shell.]

[...]

> % cp /etc/ssh/ssh_host_rsa_key.pub actual-key.b64

> Next, edit the 'actual-key.b64' file and remove the first characters
> ("ssh-rsa ").

> % base64 -d -i actual-key.b64 > actual-key.bin

> % md5sum actual-key.bin
> % sha1sum actual-key.bin

Naturally, one doesn't have to have so much files for such a
simple task. Consider instead, e. g.:

$ cut -d ' ' -f 2 < /etc/ssh/ssh_host_rsa_key.pub | base64 -d | sha1sum

[...]

--
FSF associate member #7257
0 new messages