CosmoPolitan

AWS CodeCommit에 SSH로 연동하기 (Windows / Ubuntu) (feat. git) 본문

커리어 개발 영역/01_개발 하기

AWS CodeCommit에 SSH로 연동하기 (Windows / Ubuntu) (feat. git)

BourgeoisBohemian 2019. 3. 19. 09:46

1. AWS IMA 사용자 계정에 권한 부여 (AWSCodeCommitFullAccess) 및 CodeCommit 내 Repository 생성


1-1.  사용자 계정 권한 부여

User account permissions


1-2. CodeCommit 내 Repository 생성





2. Ubuntu 서버에서의 연동


2-1. 연동할 서버(Ubuntu)의 계정에 Private Key 발급 (예시로 testserver 계정)

$ ssh-keygen


Generating public/private rsa key pair.

Enter file in which to save the key (/drive/Users/user-name/.ssh/id_rsa): /home/testserver/.ssh/codecommit_rsa


Enter passphrase (empty for no passphrase): <press Enter>

Enter same passphrase again: <press Enter>


Your identification has been saved in drive/Users/user-name/.ssh/codecommit_rsa.

Your public key has been saved in drive/Users/user-name/.ssh/codecommit_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 . . . |

|          .      |

|                 |

|                 |

|                 |

+-----------------+


2-2. 서버 계정 폴더에 .ssh 폴더 만들고 인증서 복사 

testserver 계정이면,  /home/testserver/.ssh 폴더 내

   codecommit_rsa

   codecommit_rsa.pub 

    파일 복사


2-3. [codecommit_rsa] 파일을 열어 클립보드에 복사(메모장 복사를 추천) 후,

 AWS IMA의 [내 보안 자격증명] > [AWS CodeCommit 자격 증명] 탭 > SSH 퍼블릭 키 업로드 클릭하여 복사한 내용 저장


2-4. 퍼블릭 키 업로드 후 생성된 SSH 키 ID를 복사 후,  

      ubuntu 계정 폴더(/home/testserver/.ssh)에 config (확장자 없이) 아래 내용 입력한 파일 생성 후 저장


Host git-codecommit.*.amazonaws.com

  User [복사한 SSH 키 ID]

  IdentityFile ~/.ssh/codecommit_rsa


2-5. Git 명령어를 이용해 원하는 폴더 내에서 연동

  git clone ssh://[SSH  키 ID]@git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/[AWS CodeCommit의 Repository 명]





3. Windows Client 환경에서의 연동


3-1. PUTTYgen 을 이용한 .ppk 생성

  - Save private key를 클릭하여 .ppk 파일 생성

  - 키 내용을 복사하여 클립보드(또는 메모장)에 저장


3-2. 클립보드에 복사(메모장 복사를 추천) 후

 AWS IMA의 [내 보안 자격증명] > [AWS CodeCommit 자격 증명] 탭 > SSH 퍼블릭 키 업로드 클릭하여 복사한 내용 저장



3-3. 퍼블릭 키 업로드 후 생성된 SSH 키 ID를 복사 후, 아래와 같이 GIT 연동 생성 (Git clone ; 한글 메뉴명 Git 복제하기)


- URL : ssh://[SSH  키 ID]@git-codecommit.ap-northeast-2.amazonaws.com/v1/repos/[AWS CodeCommit의 Repository 명]

   * 서울 Region은 ap-northeast-2 입니다.

- 폴더 : Git 연동할 로컬PC의 폴더명

- Putty키 쓰기 : PUTTYgen으로 생성한 privatekey의 파일경로 지정





[참고]

https://www.dev4press.com/blog/tutorials/2017/aws-codecommit-git-with-tortoisegit-using-ssh/

https://docs.aws.amazon.com/ko_kr/codecommit/latest/userguide/setting-up-ssh-windows.html


Comments