Skip to content

Instantly share code, notes, and snippets.

@dsdanielpark
Last active April 11, 2023 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsdanielpark/47f04d9522a1b2b783c2107e90f60cf5 to your computer and use it in GitHub Desktop.
Save dsdanielpark/47f04d9522a1b2b783c2107e90f60cf5 to your computer and use it in GitHub Desktop.
manage mutiple git ssh

SSH rsa key gen in local storage

   2 cd ~/.ssh
   
   3 ls -al

   # SSH Keygen
   5 ssh-keygen -t rsa -C "gitId1@gmail.com" -f "id_rsa_gitId1"
   6 ssh-keygen -t rsa -C "gitId2@gmail.com" -f "id_rsa_gitId2"

   16  cd ~/.ssh
   17  eval "$(ssh-agent -s)"               # activate ssh
   
   18  ssh-add ~/.ssh/id_rsa_[gitId1]
   19  ssh-add ~/.ssh/id_rsa_[gitId2]

register SSH rsa public key to web gitid setting. (setting - ssh)

   
   22  code ~/.ssh/id_rsa_[gitId1].pub         
   23  code ~/.ssh/id_rsa_[gitId2].pub         

SSH config setting

code ~/.ssh/config

config

Host github.com
   HostName github.com
   User [gitId1]@gmail.com
   IdentityFile ~/.ssh/id_rsa_[gitId1]
   

Host github.com
   HostName github.com
   User [gitId1]@gmail.com
   IdentityFile ~/.ssh/id_rsa_[gitId2]

Then clone via SSH using host

when want to change host name like this

Host github.com
   HostName github.com
   User [gitId1]@gmail.com
   IdentityFile ~/.ssh/id_rsa_[gitId1]
   

Host github.com.workplace
   HostName github.com
   User [gitId1]@gmail.com
   IdentityFile ~/.ssh/id_rsa_[gitId2]

git@[Host]:DSDanielPark/deeptechlog.git

git@github.com.workplace:DSDanielPark/deeptechlog.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment