title: Set up for SSH connection from a public server to private server- EC2?
body: <p>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)</p>
  
  <pre><code>[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).
  </code></pre>
  
  <p>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. </p>
  
  <p>I've googled but couldn't find a straight way to fix this.</p>
  
  <p>Updated:</p>
  
  <p>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:</p>
  
  <pre><code>ssh ec2-user@10.0.20.71
  </code></pre>
  
  <p>One Ans: default key location can be used. (Identity File)</p>
  
  <p><a href="https://stackoverflow.com/questions/84096/setting-the-default-ssh-key-location">Setting the default ssh key location</a></p>