I have an EC2 Linux server which has public IP in subnet a, besides I've made another EC2 server in subnet b, which has a private IP. Both servers are in the same VPC. I want to ssh to the private server from the public server. The SSH port is open on the security group setup of the servers. But I got permission denied (Public IP)
[ec2-user@ip-10-0-10-62 ~]$ ssh ec2-user@10.0.20.71
The authenticity of host '10.0.20.71 (10.0.20.71)' can't be established.
RSA key fingerprint is 11:19:79:39:a3:04:d2:23:5e:af:9e:c6:98:9c:7b:bd.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.20.71' (RSA) to the list of known hosts.
Permission denied (publickey).
I believe, I need to add the public key of private-server into public-server somehow. But I don't know the proper way for it and if I'm missing some other setup.
I've googled but couldn't find a straight way to fix this.
Updated:
If I use add agent, then only from my pc I can ssh to the private server and if there would be more users that need to ssh to the private server, all needs to do agent forwarding so I'm not sure if that's the best way for this case. What if I use key when I want to connect to public server, then ssh to private server without using key. Like:
ssh ec2-user@10.0.20.71
One Ans: default key location can be used. (Identity File)