Unable to access https://git-codecommit.ca-central-1.amazonaws.com The requested URL returned an error: 403

When you are trying to clone the repository then an error occurs. To solve this issue follow the steps given below.

configuration for CodeCommit

Before you can connect to AWS CodeCommit for the first time, you must complete the initial configuration steps. After you set up your AWS profile and computer you can connect to a CodeCommit repository and then clone that repository to your computer (also known as creating a local repo)

Step 1: Initial configuration for CodeCommit

  • For the configuration for CodeCommit, we have to follow these steps.
  • Create an AWS account by going to aws.amazon and choosing Sign Up.
  • Create an IAM user, or use an existing one, in your AWS account. Make sure you have an access key ID and a secret access key associated with that IAM user.
  • Sign in to the AWS Management Console and open the IAM console.
  • In the IAM console, under the navigation pane, choose Users, and then choose the IAM user you want to configure for CodeCommit access.
  • On the Permissions tab, choose Add Permissions.
  • In Grant permissions, choose Attach existing policies directly.
  • From the list of policies, select AWSCodeCommitPowerUser or another managed policy for CodeCommit access.

Step 2: Install Git

To install Git, we recommend websites such as Git Downloads.

install Git

Step 3: Set up the public and private keys for Git and CodeCommit

Open the Bash emulator. From the emulator, run the ssh-keygen command, and then save the file to the .ssh directory for your profile. Sample code is given below

$ ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/drive/Users/user-name/.ssh/id_rsa): Type a file name here, for example /c/Users/user-name/.ssh/rsa

Enter passphrase (empty for no passphrase): <Type a passphrase, and then press Enter>
Enter same passphrase again: <Type the passphrase again, and then press Enter>

Your identification has been saved in drive/Users/user-name/.ssh/rsa.
Your public key has been saved in drive/Users/user-name/.ssh/rsa.pub.
The key fingerprint is:
45:63:d5:99:0e:99:73:50:5e:d4:b3:2d:86:4a:2c:14 user-name@client-name
The key's randomart image is:
+--[ RSA 2048]----+
|        E.+.o*.++|
|        .o .=.=o.|
|       . ..  *. +|
|        ..o . +..|
|        So . . . |
|          .      |
|                 |
|                 |
|                 |

This generates:

  • The rsa file, which is the private key file.
  • The rsa.pub file, which is the public key file

Now run the following commands to display the value of the public key file (rsa.pub):

cd .ssh
notepad rsa.pub

Copy the contents of the file, and then close Notepad without saving. The contents of the file look similar to the following:

DgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDAS=EXAMPLE user-name@computer-name
  1. In the IAM console, in the navigation pane, choose Users, and from the list of users, choose your IAM user.
  2. On the user details page, choose the Security Credentials tab, and then choose the Upload SSH public key.
  3. Paste the contents of your SSH public key into the field, and then choose Upload SSH public key.
  4. Copy or save the information in SSH Key ID (for example, AKIATDBYMTTTWXP2O6H6).
configuration for CodeCommit

In the Bash emulator, run the following commands to create a config file in the ~/.ssh directory.

notepad ~/.ssh/config

Add the following lines to the file, where the value for User is the SSH key ID you copied earlier, and the value for IdentityFile is the path to and name of the private key file:

Host git-codecommit.*.amazonaws.com
  IdentityFile ~/.ssh/codecommit_rsa

Save the file as config (not config.txt), and then close Notepad. Now run the following command to test your SSH configuration:

ssh git-codecommit.us-east-2.amazonaws.com

Step 4: Connect to the CodeCommit console and clone the repository

  1. Open the CodeCommit console.
  2. Find the repository you want to connect to from the list and choose it. Choose Clone URL, and then choose the protocol you want to use when cloning or connecting to the repository. This copies the clone URL.
    • Copy the HTTPS URL if you are using either Git credentials with your IAM user.
    • Copy the HTTPS (GRC) URL if you are using the git-remote-code commit command on your local computer.
    • Copy the SSH URL if you are using an SSH public/private key pair with your IAM user.
git-remote-code commit

In the Bash emulator, run the git clone command with the SSH URL you copied to clone the repository. This command creates the local repo in a subdirectory of the directory where you run the command. For example, to clone a repository named MyDemoRepo to a local repo

git clone ssh://git-codecommit.us-east-2.amazonaws.com/v1/repos/MyDemoRepo 

For more information, see Connect to the CodeCommit repository by cloning the repository and create a commit.

Next Article

Git commands cheat sheet

Please share this post:
Posts created 31

Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

%d bloggers like this: