FYI: AWS Key Pairs are location dependent

I just got bit by this after trying to connect to a t2 micro instance I setup.

Error message I received: Permission denied (publickey)

After going through the recommended troubleshooting for this (see here and here), I came across this note from the AWS EC2 instance setup instructions:

However, key pairs are specific to a region; for example, if you plan to launch an instance in the US East (Ohio) Region, you must create a key pair for the instance in the US East (Ohio) Region.

I have instances running in US West (Northern California) AND US West (Oregon).

Why? Because the first is closer to my location while the 2nd option is the closest location that allows for GPU powered “p2” instances.

In my case, I was trying to connect to my instance using a key created under a different location … and this is why I got the “Permission denied (publickey)” exception. I’ve seen then made the location my keys were created under part of the name (e.g., aws-key-nca, aws-key-or).

2 Likes

That’s a good point - pretty much everything in AWS is location specific. It’s pretty annoying, frankly…

BTW the difference in latency between Oregon and CA is unlikely to be significant for anything other than gaming.