[File] [PATCH] of Magdir/ssh for PuTTY private key *.ppk

Christos Zoulas christos at zoulas.com
Fri Feb 7 18:47:04 UTC 2020


On Feb 7,  4:20pm, joerg.jen.der.ek at gmx.net (=?UTF-8?Q?J=c3=b6rg_Jenderek?=) wrote:
-- Subject: [File] [PATCH] of Magdir/ssh for PuTTY private key *.ppk

| Hash: SHA1
| 
| Hello,
| 
| some days ago i must create SSH keys to access my "FreiFunk" router.
| I use the SSH client tool PuTTY. This tool stores the keys in own
| file format with file name extension ppk. When running file command
| version 5.38 on such examples most are only described as ASCII text.
| 
| Furthermore with -i only mime type "text/plain" is shown and with
| - --extension option only ??? is displayed.
| 
| So i add lines to Magdir/ssh.
| On Wikipedia i found a page about Simon Tatham open source ssh
| client. So i add that page as reference by comment line like:
|  # URL:		https://en.wikipedia.org/wiki/PuTTY
| The file format is visible by looking at PuTTY c source like
| sshpubk.c. So this is expressed by comment line like
|  # Reference:	https://the.earth.li/~sgtatham/putty/latest/
|  # putty-0.73.tar.gz/sshpubk.c
| 
| According to c-source such files always start with the same phrase.
| So recognition is done by magic line like
|  0	string	PuTTY-User-Key-File-	PuTTY Private Key File
| Instead mime type text/plain a used defined one is used. This and
| the specific filename extension is shown by lines
|  !:mime	application/x-putty-private-key
|  !:ext	ppk
| 
| After this phrase the version like 1 or 2 is stored. This
| information is shown by additional line
|  >20	string		x			\b, version %.1s
| Nowadays version 2 is up-to-date. Unfortunately i found no old real
| word version 1 example. So generate sample putty-v1-header.ppk for
| testing.
| 
| The next phrase is the name of the algorithm like ssh-dss, ssh-rsa,
| ecdsa-sha2-nistp256 or ssh-ed25519. This is shown by line
|  >23	string		x			\b, algorithm %s
| 
| The next text line says "Encryption: " plus an encryption type like
| aes256-cbc or none. This is shown by lines
|  >32	search/13	Encryption:\040		\b, Encryption
|  >>&0	string		x			%s
| 
| The next line says "Comment: " plus the comment string. This is
| shown by lines:
|  >>>&0	search/3	Comment:\040
|  >>>>&0	string		x			"%s"
| 
| After applying the above mentioned modifications by patch
| file-5.38-ssh-ppk.diff then i get an output like:
| 
| dsa-key-8192.ppk:            PuTTY Private Key File, version 2,
| 			     algorithm ssh-dss, Encryption none
| 			     "dsa-key-8192"
| dsa-key-test-2048.ppk:       PuTTY Private Key File, version 2,
| 			     algorithm ssh-dss, Encryption none
| 			     "dsa-key-test-2048"
| ecdsa-key-ECDSA-nist256.ppk: PuTTY Private Key File, version 2,
| 			     algorithm ecdsa-sha2-nistp256,
| 			     Encryption none
| 			     "ecdsa-key-ECDSA-nist256"
| ed25519-key-test.ppk:        PuTTY Private Key File, version 2,
| 			     algorithm ssh-ed25519, Encryption none
| 			     "ed25519-key-test"
| putty-v1-header.ppk:         PuTTY Private Key File, version 1,
| 			     algorithm ssh-rsa, Encryption none
| 			     "putty version 1 test"
| rsa-key-1024.ppk:            PuTTY Private Key File, version 2,
| 			     algorithm ssh-rsa, Encryption none
| 			     "rsa-key-1024"
| rsa-key-16384.ppk:           PuTTY Private Key File, version 2,
| 			     algorithm ssh-rsa, Encryption none
| 			     "rsa-key-16384"
| rsa-key-256.ppk:             PuTTY Private Key File, version 2,
| 			     algorithm ssh-rsa, Encryption none
| 			     "rsa-key-256"
| rsa-key-test-4096.ppk:       PuTTY Private Key File, version 2,
| 			     algorithm ssh-rsa, Encryption aes256-cbc
| 			     "rsa-key-test-4096"
| ssh1-test.ppk:               OpenSSH RSA1 private key, version 1.1
| 
| I hope my diff file can be applied in future version of
| file utility.
| 
| For SSH key in other formats some variants are still missing. I
| will try to look for these missing SSH formats.

Great, applied!

christos


More information about the File mailing list