Kategori : Git10 November 2020 08:10:34

Git With Specific SSH Key

Lately, I use gitlab for some project, but then problem happen since gitlab did not accept duplicate ssh key for deployment server, so I create other ssh key on my deployment server. After that I expect that git will work like magic and know where the new ssh key haha, but reality is not always like expectation, git did not know where the ssh key, we need to specify a specific ssh key. After some google, I found that there are many ways to do this.

We can create ssh config in ~/.ssh/config:

Host github.com
  User git
  Hostname github.com
  IdentityFile ~/.ssh/id_rsa

After we save the file, git should now where the ssh key, but since I'm lazy, I'm not test this method and I do not know if this method will work nicely haha.

I'm simple man :D, what I've use is using this one line command bellow :

git -c core.sshCommand="ssh -i ~/.ssh/some_custom_rsa" clone/pull/push your_repo.git

Command above work locally and only applies once. There is more ways to do this, you can read it here : https://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use

Share : Share Facebook Share Twitter
Kategori : Git10 November 2020 08:10:34

zuka.one
©2011