{"id":1767,"date":"2020-03-25T15:55:15","date_gmt":"2020-03-25T12:55:15","guid":{"rendered":"https:\/\/artem.services\/?p=1756"},"modified":"2022-02-25T22:37:55","modified_gmt":"2022-02-25T19:37:55","slug":"1767","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1767&lang=en","title":{"rendered":"CodeCommit &#8212; Git"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-214\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png\" alt=\"\" width=\"975\" height=\"450\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo.png 975w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-300x138.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-768x354.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/11\/AWS-Logo-954x440.png 954w\" sizes=\"(max-width: 975px) 100vw, 975px\" \/><\/p>\n<h3>HTTPS<\/h3>\n<p>In order to be able to work with the <strong>Git<\/strong> repository in <strong>CodeCommit<\/strong> using the <strong>AIM<\/strong> role, <a href=\"https:\/\/artem.services\/?p=1761&amp;lang=en\" target=\"_blank\" rel=\"noopener noreferrer\">AWS Cli<\/a> must be installed on the instance. You will also need &quot;<strong>credential-helper<\/strong>&quot;, for this we create a configuration file for <strong>Git<\/strong>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n~\/.gitconfig\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>And copy the following into it:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[credential]\r\n    helper = !aws codecommit credential-helper $@\r\n    UseHttpPath = true\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Now you can work with <strong>CodeCommit<\/strong> over <strong>HTTPS<\/strong> without specifying a username\/password.<\/p>\n<p>&nbsp;<\/p>\n<h3>SSH<\/h3>\n<p>To use the <strong>SSH<\/strong> protocol, you need an <strong>IAM<\/strong> user with rights to <strong>CodeCommit<\/strong>. You also need to add the <strong>SSH Public Key<\/strong>, for this, in the <strong>IAM<\/strong> settings of the user, go to the &quot;<strong>Security Credentials<\/strong>&quot; tab and go down to the &quot;<strong>SSH keys for AWS CodeCommit<\/strong>&quot; block<\/p>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1757\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33.png\" alt=\"\" width=\"2192\" height=\"444\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33.png 2192w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-300x61.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-1024x207.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-768x156.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-1536x311.png 1536w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-2048x415.png 2048w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-954x193.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2020\/03\/Screenshot-2020-03-25-at-14.34.33-1354x274.png 1354w\" sizes=\"(max-width: 2192px) 100vw, 2192px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>And upload the public key. After which you will see the &quot;<strong>SSH Key ID<\/strong>&quot; of your key, it is needed to work with <strong>CodeCommit<\/strong>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngit clone ssh:\/\/{YOUR_ID_FOR_SSH_KEY}@git-codecommit.us-east-1.amazonaws.com\/v1\/repos\/artem-test\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>But in order not to constantly indicate it, you can specify it in the <strong>SSH<\/strong> configuration:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nvim ~\/.ssh\/config\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Copy the following contents:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nHost git-codecommit.*.amazonaws.com\r\nUser {YOUR_ID_FOR_SSH_KEY}\r\nIdentityFile ~\/.ssh\/id_rsa # path to your private ssh key\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>And provide the necessary permission to it:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nchmod 600 ~\/.ssh\/config\r\n<\/pre>\n<p>Now you can work with <strong>CodeCommit<\/strong> without specifying &quot;<strong>SSH Key ID<\/strong>&quot;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTPS In order to be able to work with the Git repository in CodeCommit using the AIM role, AWS Cli must be installed on the instance. You will also need &quot;credential-helper&quot;, for this we create a configuration file for Git: &nbsp; And copy the following into it: &nbsp; Now you can work with CodeCommit over &hellip; <a href=\"https:\/\/artem.services\/?p=1767&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;CodeCommit &#8212; Git&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[599],"tags":[543,877,1435,433,409,861],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1767"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1767"}],"version-history":[{"count":4,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1767\/revisions"}],"predecessor-version":[{"id":2217,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1767\/revisions\/2217"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}