Could not ssh into AWS EC2 server
<p>I am facing interesting problem. I have launched an ec2 instance which is ubuntu 14.04. I can ssh into it by providing key file like below.</p>

<pre><code>ssh -i "xxxxx.pem" ubuntu@xxxxxxxxxxxx.ap-south-1.compute.amazonaws.com
</code></pre>

<p>But I thought of making another account in instance rather than using ubuntu(root) always which is not safe. So I have created another account on my name in server. And for more security I thought of creating private(<code>id_rsa</code>) and public(<code>id_rsa.pub</code>) key files. And put the public key in server <code>.ssh/authorized_keys</code> and I should be able to ssh from my new account from my local machine. Which is also worked. now I can ssh into server like below.</p>

<pre><code>ssh naroju@XXXXXXXXXXXXXXX.ap-south-1.compute.amazonaws.com
</code></pre>

<p>Now the problem comes. Although I can ssh into to it from my new account, I cannot ssh into server from my ubuntu(root) account. It gives below error.</p>

<pre><code>Permission denied (publickey).
</code></pre>

<ol>
<li>Why is it giving me this error?</li>
<li>I wonder why did it ssh into server from my new account, does not it require private key file(<code>.pem</code> file of AWS) ? </li>
</ol>