Development

GitLab 연결 및 프로젝트 Push

애리얼·2019년 10월 29일·조회 9,123

1. 개요


2. 사전과정


3. GitLab 연결

  • 저는 external_url을 gitlab.arieljei.com이라고 설정했으므로 클라이언트의 /etc/hosts 파일에 gitlab.arieljei.com에 GitLab 서버 ip로 설정했습니다.
  • 그리고 GitLab에는 devops라는 계정을 만들었고
  • gitlab-test라는 프로젝트를 생성해 놓은 상태입니다.

그리고 다음 명령들을 통해 push까지 했구요.

$ git clone http://gitlab.arieljei.com/devops/gitlab-test.git
Cloning into 'gitlab-test'...
Username for 'http://gitlab.arieljei.com': devops
Password for 'http://devops@gitlab.arieljei.com':
warning: You appear to have cloned an empty repository.
$ cd gitlab-test
$ touch README.md
$ git add .
$ git commit -m "first"
[master (root-commit) 75ccc8d] first
 Committer: Ubuntu 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
$ git push -u origin master
Username for 'http://gitlab.arieljei.com': devops
Password for 'http://devops@gitlab.arieljei.com':
Counting objects: 3, done.
Writing objects: 100% (3/3), 228 bytes | 228.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://gitlab.arieljei.com/devops/gitlab-test.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

이렇게 GitLab에서도 확인 완료입니다.


4. GitLab 연결 with SSH Key

이번에는 SSH Key를 생성하여 연결해볼꺼예요.

일단 SSH Key를 생성하고 -> 공개키를 GitLab에 업로드합니다.

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:bUL2ACN/j3YZT7BdZWMeSJhEbjrT7iwC7wF93FA0234 ubuntu@ip-172-31-8-20
The key's randomart image is:
+---[RSA 2048]----+
|    . o   =*+.o=o|
|     o o  o*+oo.o|
|      . =.o+o. . |
|      .+.**=.    |
|     . .S*Bo.. E |
|     ....++   .  |
|      o.   .     |
|       o..o      |
|      ... .o     |
+----[SHA256]-----+

그러면 id_rsa.pub 파일이 생성돼요. 이 파일을 devops 계정으로 접속 후에 GitLab -> Settings -> SSH Keys를 통해 키를 추가합니다.

최종적으로는 Git 프로젝트에서 SSH Key 탭에서 할당된 키가 보여야 합니다.

$ git clone git@gitlab.arieljei.com:devops/gitlab-test.git
Cloning into 'gitlab-test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

이제 키로 인증받고 잘 됩니다.

댓글 0

로그인 후 댓글을 남길 수 있습니다.

아직 댓글이 없습니다.