Ssh from mac using .pem file

Aniruddha Tekade
2 min readSep 17, 2019

One very quick article if you’re struggling to connect to the remote server machine using .pem file stored on you mac.

The .pem file are quite successful when it comes to connecting to the server machine using SSH in the world of cloud. Those who work with AWS quite often are very well versed with it, I suppose.

However on macOS, I came across a very weird issue. I have two users eng_qa and support_qa which are created on the server machines running on CentOS 6.10. From any linux based machine, I was able to access connect or ssh to the server. However, from my mac I could not. So I spent a few hours to debug this, compared both /etc/ssh/ssh_config and /etc/ssh/sshd_config with same files on my local, restarted the sshd service, perform ssh-add and ssh-add-l but nothing worked out.

Somewhere while googling, I noticed a used mentioned on a Github issues that he was not able to connect to AWS EC2 instance running Ubuntu via ssh from his mac. So he found out that the recent version of OpenSSH after the High Sierra Upgrade on mac caused this issue. It had nothing to do with the settings on the local or remote servers. And I got my answer.

Problem:

ssh -i server_user_name.pem user_name@10.10.10.25

yielded error — ssh failed Permission denied (publickey, gssapi-keyex, gssapi-with-mic).

Solution:

  1. Open terminal and go the your .ssh/ directory
  2. Create a file called config
  3. Add the following 1 line configuration in this file
Host * PubkeyAcceptedKeyTypes=+ssh-dss

4. Save and exit the file.

You do not need to restart the ssh daemon. It should just work fine.

--

--

Aniruddha Tekade

Super interested in Computer Science & Software Engineering with focus on AI, ML, Kubernetes