Sử Dụng Nhiều SSH Key Trên Cùng Một Thiết Bị


1

Tạo file config

cd ~/.ssh
sudo vim config
2

Generate file SSH key

ssh-keygen -t ed25519 -C "email-cua-ban" -f ~/.ssh/cong-ty-1
ssh-keygen -t ed25519 -C "email-cua-ban" -f ~/.ssh/cong-ty-2
3

Cấu hình file config

sudo vim config
Host cong-ty-1.com
	HostName github.com
	User git
	IdentityFile ~/.ssh/cong-ty-1
Host cong-ty-2.com
	HostName gitlab.com
	User git
	IdentityFile ~/.ssh/cong-ty-2
4

Cấp quyền cho SSH key

pbcopy < ~/.ssh/company_account.pub

Tuỳ vào công ty sẽ lưu trữ source code ở đâu, các bạn vào phần cài đặtadd SSH key tương ứng

5

Sử dụng

git clone [email protected]:cong-ty-1/repo.git
git clone [email protected]:cong-ty-2/repo.git

Last updated