Issue
When I try to connect to an EC2 in a private network through a bastion server I get this message:
<username>@<ec2-server>: Permission denied (publickey)
However, I can ssh to bastion from my local machine, and I can ssh to the EC2 from the bastion server,
Here is the .ssh/config
I'm using:
Host <ec2-servers>*
IdentityFile ~/.ssh/id_rsa
User <username>
Here is the command I use to ssh:
ssh -J <bastion-server> <ec2-server>
Note: Permissions are good (700 for ~/.ssh/
and 600 for ~/.ssh/*
)
Thanks in advance for your help!
Solution
Fixed it by adding local ssh public key in the authorized_keys
of the remote ec2 instance.
Answered By - Arsalen