Post Date: August 19, 2016
Last Updated: November 2026
Introduction
If you use PuTTY on Windows to connect to remote Linux servers, you may have a private key saved in the .ppk format. However, when connecting to servers through the macOS Terminal or OpenSSH, you may need to convert the key into a compatible format.
In this guide, we will explain how to convert PPK key to PEM on Mac using PuTTYgen. We will install PuTTY through Homebrew, convert the private key, configure the correct file permissions, and verify the converted key using SSH.
This method is useful when migrating SSH access from Windows to macOS or when using an existing PuTTY private key with an OpenSSH-compatible client.
Prerequisites
Before converting the PPK key to PEM on Mac, ensure that you have:
- A Mac system with macOS installed.
- Homebrew package manager installed.
- An existing PuTTY private key file (
.ppk). - Access to the macOS Terminal.
If Homebrew is not installed, follow the instructions on the official Homebrew website.
Implementation
Follow the steps below to convert your PPK private key into an OpenSSH-compatible private key on macOS.
Step 1: Open Terminal on Mac
Open the Terminal application on your Mac.
You can find it under:
Applications → Utilities → Terminal
Alternatively, use Spotlight Search and type Terminal to open it.
Step 2: Install PuTTY Using Homebrew
PuTTY provides the PuTTYgen utility, which allows you to convert private keys between supported formats.
First, install PuTTY using the Homebrew package manager:
brew install putty
After installation, verify that PuTTYgen is available:
puttygen --version
If the command displays the installed version, PuTTYgen is ready to use.
For more information, refer to the official PuTTY documentation.
Step 3: Navigate to the PPK Key Location
Navigate to the directory containing your existing .ppk private key.
For example, if your key is stored in the Downloads directory, execute:
cd ~/Downloads
You can list the files in the directory using:
ls -l
Make sure your PPK file is available before proceeding.
Step 4: Convert the PPK Key to PEM Format
Execute the following command to convert the PPK private key into an OpenSSH-compatible private key:
puttygen key.ppk -O private-openssh -o key.pem
Here:
key.ppkis your existing PuTTY private key file.-O private-opensshspecifies the OpenSSH private key output format.-o key.pemspecifies the output filename.
Replace key.ppk with your actual private key filename.
For example:
puttygen server-access.ppk -O private-openssh -o server-access.pem
After executing the command, the converted private key will be saved as server-access.pem in the current directory.
Note: The .pem extension is the filename extension. The private-openssh option determines the actual key format generated by PuTTYgen.
Step 5: Change the PEM File Permissions
SSH requires private key files to have appropriately restricted permissions.
Change the permissions of the newly generated PEM file using:
chmod 600 key.pem
This command grants read and write permissions to the file owner while preventing access by other users.
Verify the permissions using:
ls -l key.pem
The output should look similar to:
-rw------- 1 user staff 1675 Nov 2 18:00 key.pem
The file should be accessible only to its owner.
Step 6: Verify the Converted PEM Key
After converting the PPK key to PEM format, you can verify that the key works by connecting to your remote Linux server using SSH.
Execute:
ssh -i key.pem username@SERVER_IP
Replace:
key.pemwith the converted private key filename.usernamewith the remote server’s SSH username.SERVER_IPwith the remote server’s IP address or hostname.
If the private key is valid and the server accepts the corresponding public key, the SSH connection should succeed.
If you receive a permission error, verify the file permissions and ensure that you are using the correct username, server address, and private key.
Important Security Notes
When you convert a PPK key to PEM on Mac, remember that both files contain sensitive private key material.
- Never share your private key through email, public repositories, or unsecured storage.
- Keep the original PPK file as a backup until the converted key has been tested successfully.
- Use
chmod 600to restrict access to the converted private key. - Do not modify or overwrite the original private key during conversion.
- Store private keys in a secure location on your Mac.
Conclusion
Converting a PPK key to PEM on Mac is straightforward using PuTTYgen and Homebrew. By installing PuTTY, executing the conversion command, and configuring the correct file permissions, you can use an existing PuTTY private key with the macOS OpenSSH client.
This process is particularly useful when migrating SSH access from Windows to macOS or managing remote Linux servers from different operating systems.
Frequently Asked Questions
1. Can I convert a PPK key to PEM on Mac?
Yes. You can use PuTTYgen, which is included with PuTTY, to convert a PPK private key into an OpenSSH-compatible private key on macOS.
2. How do I install PuTTYgen on Mac?
You can install PuTTY using Homebrew:
brew install putty
This installs PuTTYgen, which you can use to convert private keys.
3. What is the command to convert PPK to PEM on Mac?
Use the following command:
puttygen key.ppk -O private-openssh -o key.pem
Replace key.ppk with your source key filename and key.pem with your preferred output filename.
4. Why do I need to run chmod 600 on a PEM file?
The chmod 600 command restricts the private key file permissions to its owner. SSH may reject a private key if its permissions allow other users to access it.
5. Can I use the converted PEM key with SSH on Mac?
Yes. The converted OpenSSH private key can be used with the macOS SSH client, provided the corresponding public key is authorized on the remote server.
6. Does converting PPK to PEM change the SSH key?
The conversion changes the private key’s file format, not the underlying key pair. The corresponding public key remains associated with the same private key.
Related Articles
How to SSH remote server via Terminal
How to Troubleshoot SSH Connection Issues in AWS EC2
Talk to Our Technology Experts
Need help managing SSH keys, securing remote access, or administering your Linux servers? Our team can set up key-based authentication, harden your SSH configuration, and protect your server access with our Security Services.
