Wednesday, July 1, 2015

Converting .ppk to OpenSSH

PuTTY Private Key (.ppk) could be exported to an OpenSSH key allowing it to be used with an OpenSSH client on linux terminal.
1. The private key contained within the ppk is exported to OpenSSH with the use of puttygen.exe
2. Run puttygen.exe and load the existing private key file

Same could be achieved on command line with
puttygen.exe puttykey.ppk  -O private-openssh
When the file is loading it will prompt for the passphrase.
3. Once the correct passphrase is entered the private key will be loaded.

4. Select "Export OpenSSH key" item under the conversions menu and save the key.

5. Copy the key file to linux server to be be used with the OpenSSH client.



6. Change the protection of the key file to 400. Without it ssh client will issue the following warning and will not connect.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'myssh.key' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: myssh.key
Once the file permission is changed, it could be used with the OpenSSH client.
chmod 400 myssh.key
$ ssh oracle@dbserver  -p 2356 -i myssh.key
Enter passphrase for key 'myssh.key':