When I run a Git command when using AWS CodeCommit, I get the error message “Permission Denied (publickey). Fatal: Could not read from remote repository. Please make sure you have the correct access rights”. How can I fix this?

This error message refers to your SSH public key when connecting to a CodeCommit repository. It is generated because CodeCommit expects different credentials than the ones that it’s receiving. To resolve the issue, verify permissions for the SSH key on your desktop config settings, and ensure the IAM user has the proper SSH key.

You might want to consider generating Git credentials and using HTTPS instead of SSH because Git credentials are compatible with most IDEs and Git clients.

If you do want to use SSH, follow the instructions at Associate Your Public Key with Your IAM User. For a more detailed guidance on Linux, macOS, or Unix, see Setup Steps for SSH Connections to AWS CodeCommit Repositories on Linux, macOS, or Unix.

After testing your SSH connection, you should now be able to use CodeCommit successfully.

Note: If you are running Windows, these instructions should work as long as you are running a Bash emulator. For more information, see Setup steps for SSH Connections to AWS CodeCommit Repositories on Windows.

CodeCommit, permission, denied, Git


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2017-1-27