So there are plenty of tutorials on how to convert a PEM
to a PPK
using puttyGen
. However my issue is that my windows machine had the only PEM
copy and I converted it into a PPK
and deleted it. Now I need to figure out how to convert a PPK
into a PEM
so that my mac can ssh
into the server. I still have access to the server so I could also just make a new key if I had to, anyone know how to convert PPK
to PEM
?
Asked
Active
Viewed 8.1k times
50
-
How is this related to Linux? The server to which you're trying to connect is running it? – Kenny Evitt Jun 19 '18 at 23:39
-
Linux also uses PEMs. But I agree the tag is a little misleading. – icedwater Sep 18 '18 at 03:26
4 Answers
100
Install PuttyTools
apt-get install putty-tools
Generate a
pem
file form theppk
puttygen server.ppk -O private-openssh -o server.pem
The file server.pem file will be saved on same location
scopchanov
- 6,933
- 10
- 30
- 56
Emizen Tech
- 3,329
- 1
- 15
- 33
-
9Since the OP mentioned using the .pem key on a Mac, I'll just mention that you can run the same `puttygen` command on the Mac after installing the `putty` package using Homebrew. – Erhhung Mar 06 '17 at 11:50
-
4on centos / redhat : 'yum install putty' provides the relevant executable – Bryji Oct 10 '17 at 14:08
-
-
2
10
If you're on a Mac and you've previously installed Homebrew, from Terminal:
$ brew install putty
$ puttygen server.ppk -O private-openssh -o server.pem
The first command was suggested in this comment and the second from Emizen Tech's answer.
Kenny Evitt
- 8,023
- 5
- 59
- 84
2
Try this to install putty-tools
sudo apt install putty-tools
puttygen key.ppk -O private-openssh -o key.pem
ssh -i ~/key.pem {user}@{ip}
osanger
- 2,057
- 3
- 24
- 28
Jayanta Mukherjee
- 41
- 1
2
First, install PuTTY for Mac using
brew install putty
Then, use the following command to convert the .ppk format private key to a standard PEM format private key:
puttygen privatekey.ppk -O private-openssh -o privatekey.pem
Make sure permissions on the private key file are set properly. It should only be readable by the user that owns it.
chmod go-rw privatekey.pem
You can now use the key for logins from scripts and command line with:
ssh -i privatekey.pem user@hostname
Salman Iftikhar
- 301
- 2
- 9
-
On the final `ssh` I get Enter passphrase for key - I enter the login password and I get Invalid key length. – dashman Nov 20 '18 at 14:35