1) ssh key 생성
2) github에 key 등록
3) config에 Host에 -username 을 추가해 줌
4) git clone 시에도 git@github.com-username:username ... 추가
> cd ~/.ssh
> ssh-keygen -t ed25519 -C "ashappyasitis@gmail.com" -f "id_ed25519_github_ashappy"
> ssh-keygen -t ed25519 -C "kevin-jang@gmail.com" -f "id_ed25519_github_kevin"
https://github.com/settings/keys
폴더 이동 및 파일 만들기
> cd ~/.ssh
> vim config
config 파일 내용
Host github.com-ashappyasitis
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_ed25519_github_ashappy
Host github.com-kevin-jang
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_ed25519_github_kevin
> cd ~/workspace
> git@github.com-ashappyasitis:ashappyasitis/mysql-deadlock-example.git
> git@github.com-kevin-jang:kevin-jang/my-example.git
username: ashappyasitis
clone 명령어: git clone git@github.com:ashappyasitis/mysql-deadlock-example.git
username: kevin-jang
clone 명령어: git clone git@github.com:kevin-jang/my-example.git
GitHub 무료 버전을 사용하고 있는 경우
> cd ~/.ssh
> ssh-keygen -t ed25519 -C "ashappyasitis@gmail.com" -f "id_ed25519_github_ashappy"
Generating public/private ed25519 key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_ed25519_github_ashappy
Your public key has been saved in id_ed25519_github_ashappy.pub
The key fingerprint is:
SHA256:C/zyoDey2Xo0YF+ZAfLm7kGzmeQYNDNooq+rL17Lml8 ashappyasitis@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
| . .. |
| . o . |
|. o = o + |
|.o .oB + |
|. ..oB.S |
| . B+B . |
| ...EX.o |
|..+ +=+= |
|*B++=*o.. |
+----[SHA256]-----+
> ssh-keygen -t ed25519 -C "kevin-jang@gmail.com" -f "id_ed25519_github_kevin"
Generating public/private ed25519 key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_ed25519_github_kevin
Your public key has been saved in id_ed25519_github_kevin.pub
The key fingerprint is:
SHA256:RkwE0sEMGhqIYUE4exkzmWVAEm/2141wJMu/HaDUtL4 kevin-jang@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
|XB====++= |
|*=*+ o+O . |
|.o== = B |
|.oo. . O + |
| . . o S o |
| . . + . |
| E . |
| |
| |
+----[SHA256]-----+
https://github.com/settings/keys
> $ cat id_ed25519_github_ashappy.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEmYywcnjmM8IBtx+hE+zLNkS+A/EXyEhWDa93xkO4TC ashappyasitis@gmail.com
ashappyasitis 계정에 SSH Public key 를 등록했던 것 처럼 kevin-jang 계정에도 같은 방식으로 SSH Public key 를 등록하면 된다. 여기서는 설명을 생략 한다.
폴더 이동 및 파일 만들기
> cd ~/.ssh
> vim config
private-key를 연결 하면 된다.
Host github.com-ashappyasitis
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_ed25519_github_ashappy
Host github.com-kevin-jang
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/id_ed25519_github_kevin
FROM: git@github.com:username/repository
TO: git@github.com-username:username/repository
FROM: git@github.com:ashappyasitis/mysql-deadlock-example.git
TO: git@github.com-ashappyasitis:ashappyasitis/mysql-deadlock-example.git
> git clone git@github.com-ashappyasitis:ashappyasitis/mysql-deadlock-example.git
The authenticity of host 'github.com (20.200.245.247)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names
bash: $: command not found
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 47 (delta 3), reused 47 (delta 3), pack-reused 0
Receiving objects: 100% (47/47), 65.06 KiB | 362.00 KiB/s, done.
Resolving deltas: 100% (3/3), done.
git clone git@github.com-kevin-jang:kevin-jang/my-example.git 동작 확인은 생략