개요
- Amazon EC2 에서 GitHub Repo 를 Clone 해야 할 상황이 생겼다.
- SSH 를 이용하여 Repo 에 대한 액세스를 허용해보자.
SSH URL 복제
1. Key 생성
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:{KEY} root@ip-10-40-0-65
The key's randomart image is:
2-1. Server deploy key를 Github Repository에 등록
$ cd /root/.ssh **OR** $ cd .ssh
$ cat id_rsa.pub
GitHub
- Repo → Settings → Deploy keys → Add deploy key
- 복사한 키 붙여 넣고 Add Key
2-2. Server deploy key를 Github Account에 등록
$ ssh-keygen -t rsa -C <your github email>
$ cat id_rsa.pub **OR** type id_rsa.pub
GitHub
- Signed in as <GitHub ID> → Settings → SSH and GPG keys → New SSH key