title: git push origin master: permission denied (public key) error
body: <p>I have set up a git repo on my amazon ec2 ubuntu server instance. I have been trying to push the code onto the server's repo from my local machine. The steps that I followed are: </p>
  
  <pre><code>ssh-add /path/to/myEC2publickey
  </code></pre>
  
  <p>On my EC2 Instance</p>
  
  <pre><code>mkdir /path/my_project.git
  cd /path/my_project.git
  git init --bare
  </code></pre>
  
  <p>Later on my localhost, </p>
  
  <pre><code>cd the_project 
  git init git add . 
  git commit -m "Initial git commit message" 
  git remote add origin username@hostname.com:the_project.git 
  git config --global remote.origin.receivepack "git receive-pack" 
  git push origin master
  </code></pre>
  
  <p>Since I was getting a Permission Deined (public key) error while executing the last command (i.e. git push origin master), I set the public key using the steps given on a forum that included - </p>
  
  <pre><code>ssh-keygen -t rsa -C "myemail@somedomain.com"
  eval 'ssh-agent -s'
  ssh-add
  </code></pre>
  
  <p>I was able to add the public key but I am still facing the <strong>Permission Denied (public key)</strong> : Error. </p>
  
  <p>I'm new to git and have been looking forward to shift all my code into a git repo. </p>
  
  <p>Any help would be greatly appreciated.</p>