Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tajidyakub/4d7cfe5352a8691c759d4c7ec02410ff to your computer and use it in GitHub Desktop.
Save tajidyakub/4d7cfe5352a8691c759d4c7ec02410ff to your computer and use it in GitHub Desktop.
Multiple user ssh config file untuk remote repository github

Multiple user SSH Config untuk Github Remote Repository

Remote repository github dengan menggunakan SSH Key:

  • Generate SSH Key (RSA 2048bit) ssh-keygen -t rsa -b 2048 -C "[email protected]"
  • Masukkan public key dari key pair yang digenerate sebelumnya di Profile github

Konfigurasi SSH client di local development machine anda via ~/.ssh/config

# ~/.ssh/config - create apabila belum ada

Host github.com-user1
  User git
  Hostname github.com
  IdentityFile '~/.ssh/user1privatekey'
  
Host github.com-user2
  User git
  Hostname github.com
  IdentityFile '~/.ssh/user2privatekey'

Berdasarkan konfigurasi di atas maka ssh github.com-user1 akan melakukan upaya login ke github.com dengan user git dan private key user1 sebagaimnana didefinisikan di dalam file konfigurasi ssh

Remote Repo di repo lokal dapat ditambahkan melalui perintah berikut dengan asumsi repository lokal sudah disetup

$ cd /path/to/lokal/repo
$ git remote add origin ssh://git.521000.best-user1/usernamegithub/repo-github.git

Sesuaikan informasi user git di dalam repo lokal untuk digunakan ketika melakukan commit dan push

$ git config --local user.name "username1"
$ git config --local user.email "[email protected]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment