When you are trying to clone the repository then an error occurs. To solve this issue follow the steps given below.
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.
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 . . . | | . | | | | | | | +-----------------+
rsafile, which is the private key file.
rsa.pub file, which is the public key file
Now run the following commands to display the value of the public key file (
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:
ssh-rsa EXAMPLE-AfICCQD6m7oRw0uXOjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMCVVMxCzAJB gNVBAgTAldBMRAwDgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDASBgNVBAsTC0lBTSBDb2 5zb2xlMRIwEAYDVQQDEwlUZXN0Q2lsYWMxHzAdBgkqhkiG9w0BCQEWEG5vb25lQGFtYXpvbi5jb20wHhc NMTEwNDI1MjA0NTIxWhcNMTIwNDI0MjA0NTIxWjCBiDELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAldBMRAw DgYDVQQHEwdTZWF0dGxlMQ8wDQYDVQQKEwZBbWF6b24xFDAS=EXAMPLE user-name@computer-name
- In the IAM console, in the navigation pane, choose Users, and from the list of users, choose your IAM user.
- On the user details page, choose the Security Credentials tab, and then choose the Upload SSH public key.
- Paste the contents of your SSH public key into the field, and then choose Upload SSH public key.
- Copy or save the information in SSH Key ID (for example,
In the Bash emulator, run the following commands to create a config file in the ~/.ssh directory.
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 User AKIATDBYMTTTWXP2O6H6 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:
Step 4: Connect to the CodeCommit console and clone the repository
- Open the CodeCommit console.
- 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.
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.