# .ssh로 이동
cd ~/.ssh
# ssh-keygen 생성
# 1>
ssh-keygen -t rsa -b 4096 -C "userA@gmail.com"
Generating public/private rsa key pair.
# 2>
ssh-keygen -t rsa -C "userA@my_email.com" -f "id_rsa_userA"
# key 이름 설정
Enter file in which to save the key (/Users/ella/.ssh/id_rsa): id_rsa_userA
# 보안을 위해서 설정해야하지만...하지 않음
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_rsa_store
Your public key has been saved in id_rsa_store.pub
The key fingerprint is:
SHA256:00000000000000~~~~~~~userA@gmail.com
The key's randomart image is:
+---[RSA 4096]----+
|. o . |
| = .. o . |
| BE+ = . |
| *.* O + . |
|ooO B * S |
|+*o@ = . . |
|=o*.o + |
|oo .. . |
| .. .. |
+----[SHA256]-----+
# 확인
> .ssh ls
id_rsa_userA
id_rsa_userA.pub
id_rsa_userB
id_rsa_userB.pub
# ssh키 등록
ssh-add id_rsa_userA
# ssh key daemon 추가
$ eval "$(ssh-agent -s)" &&\
ssh-add -K id_rsa_userA
# 권한 확인
ssh-add -l
# 개인용 계정
Host userA
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_userA
# 회사용 계정
Host userB
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_userB
# mac에서 git global 설정 수정
git config --global --edit
# git global setting
[includeIf "gitdir:~/DEV/GIT-Store"]
path = DEV/GIT-Store.gitconfig
[includeIf "gitdir:~/DEV/GIT-Project"]
path = DEV/GIT-Project/.gitconfig
# GIT-Store폴더로 .gitconfig 파일 생성
cd ~/DEV/GIT-Store
vi .gitconfig
# git local setting
[user]
name = "[git name / ex> EllaDev]"
email = "[git email]"
[github]
user = "[git nickname / ex> ella-front-dev]"
# 복사 방법 1>
cat id_rsa_userA.pub | pbcopy
# 복사 방법 2>
pbcoby < id_rsa_userA.pub
# ssh -T git@{Host}로 테스트
> ssh -T git@userA
# userA 계정 저장소 clone
> git@userA:userA/repository.git
# userB 계정 저장소 clone
> git@userB:userB/repository.git
Ref>