Adding a putty .ppk key to MacOS SSH terminal.

I recently switched from Windows to macOS, while the transition was almost smooth there were some small hiccups. One of them was using my old putty .ppk file in macOS. In this post, I will explain how to convert .ppk key to .pem & add them into macOS ssh.

Requirements-

  • Internet connection to download some dependencies
  • A cup of coffee ☕️

Converting .ppk key to .pem key on a Mac

macOS by default doesn’t recognize .ppk files, so for that, we need to convert it into a .pem file. It can be done easily via homebrew & putty.

Install Homebrew

if you are booting into a fresh version of macOS there is a fair chance that homebrew isn’t installed on your Mac. To install homebrew open terminal and paste this comment and press enter.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Putty

Now, We need to install putty your machine. to do that type the following code in the terminal.

brew install putty

Generate/convert the key

First, we need to mount the folder where keys are saved in the terminal, for that you can type cd then type the path of the folder. alternatively, you can drag the folder to the terminal icon on the dock it will open in a new window.

Then type the following code in the terminal-

puttygen key.ppk -O private-openssh -o key.pem

replace the key.ppk with the original file name and key.pem with your output file name.

Fixing permission of the file.

Now if you will try to add the key to ssh, it will show an error like this.

arnabmohapatra@Arnabs-iMac key % ssh-add /Users/arnabmohapatra/Key/arnab_demo.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/Users/arnabmohapatra/Key/arnab_demo.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

This is because the permission of the output file is 0644, which is bad because it is accessible to all the users in the system, which defeats the purpose. Private keys should only be accessible to one user. To fix the permission run the following command.

chmod 400 /path/to/your/keyfile/key.pem

Adding the key to the terminal.

To add the key to the terminal run this code. you are should be good to go.

ssh-add /path/to/your/keyfile/key.pem

Here is a recording of the above process as a reference, if you get confused somewhere.

Conclusion

This was a guide for converting putty .ppk key to an Amazon .pem file on macOS. Comment below if you’ve any queries or feedback. I read and reply to each of them within 8 hours!

I am a no-code WP Developer. I am obsessed with Faster Loading Websites, Design, #SEO, #WordPress, #SaaS, and #WebPerformance.

10 thoughts on “Adding a putty .ppk key to MacOS SSH terminal.”

  1. Excellent article, slight typo on the copy command. chmod 404 /path/to/your/keyfile/key.pem should be chmod 400 /path/to/your/keyfile/key.pem

    Reply
  2. Hello,
    I have installed putty, but I can not seem to be able to find the file .ppk. I tried searching for it in the Finder but it looks like I do not have a file .ppk. Could you advise me on what can I do in this situation.

    Many thanks.

    Reply
  3. I have been looking for the answer to this forever. Thank you so much. your solution worked and I learned I needed homebrew on my mac – which i didnt have. Thanks for sharing!

    Reply

Leave a Comment

recent blogarticles

Sorry, no posts were found.

[widget id="wp_coupons_widget-3"]
Malcare WordPress Security