Linux SSH Config Alias Permission Denied (publickey)

amazon ec2linuxmacssh

I have an AWS linux instance running that I'm trying to SSH into. When I type in the manual command (using mac, terminal):

ssh -i ~/.ssh/PEM.pem root@IPADDRESS

it works fine, but when I try to give that an alias in the config file in my SSH colder, such as

Host hostname
User root
IdentityFile "file"
HostName IPADDRESS

I get the error:

Permission denied (publickey).

I have other AWS aliases in my config file with the exact same setup that work fine, any ideas? Thanks.

Update I figured out what was going on here, I had a trailing whitespace at the end of my .pem location. Man is that stuff finicky.

Best Answer

I figured out what was going on here, I had a trailing whitespace at the end of my .pem location. Man is that stuff finicky.