title: What security group settings are needed to `git clone ...` on an EC2 instance?
body: <p>From my Mac, I can <a href="https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html" rel="nofollow noreferrer">run</a>:</p>
  
  <pre><code>git clone ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo my-demo-repo
  </code></pre>
  
  <p>just fine, after running <code>ssh-keygen</code> and uploading the public key, as described in the URL above.</p>
  
  <p>Doing the same from an EC2 linux instance fails with:</p>
  
  <pre><code>Permission denied (publickey).
  fatal: Could not read from remote repository.
  
  Please make sure you have the correct access rights
  and the repository exists.
  </code></pre>
  
  <p>Yet I have the impression that the problem is not a rejection from CodeCommit's side, but insufficient permissions on the EC2 security group side. Those are set to:</p>
  
  <p><a href="https://i.stack.imgur.com/kMTqd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kMTqd.png" alt="inbound of security group"></a></p>
  
  <p><a href="https://i.stack.imgur.com/O3CkE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O3CkE.png" alt="outbound of security group"></a></p>
  
  <p>Are ssh-from-anywhere and anything-to-anywhere not sufficient? (Git underneath does use <code>ssh</code>, no?) What else should I do to be able to <code>git clone ..</code> on an EC2 instance?</p>