January 2015 Entries

Get SSH public key fingerprint with powershell

I was working on a project with SSH keys. I needed to get the key fingerprint but don't have access to ssh-keygen. So with some poking around I was able to get the MD5 hash of the base64 keyfile.Here's the code:$keyFilePath = "SSHKeyFilePath.pub" #Get the key$rawText = [System.IO.File]::ReadAllTe... = $rawText.Replace("`r","")$r... = $rawText.Replace("`n","")$r... -match "AA.+?=="$keyText = $Matches[0]#Compute the hash $md5 = new-object -TypeName System.Security.Cryptograph... ......