Closed-source quality be like

  • @[email protected]
    link
    fedilink
    111 year ago

    I don’t post my code to Github because I still couldn’t figure out how to switch SSH keys for 2 different git servers smoothly.

    • @[email protected]
      link
      fedilink
      81 year ago

      you dont have to switch

      git will automatically select one that works

      I have the same password protected ssh key for every git site i am on tho. The sites only know the public key so its fine.

    • Perhyte
      link
      English
      81 year ago

      If you’re using OpenSSH, the IdentityFile configuration directive selects the SSH key to use.

      Add something like this to your SSH config file (~/.ssh/config):

      Host github.com
        IdentityFile ~/.ssh/github_rsa
      
      Host gitlab.com
        IdentityFile ~/.ssh/gitlab_rsa
      

      This will use the github_rsa key for repositories hosted at github.com, and the gitlab_rsa key for repositories hosted at gitlab.com. Adjust as needed for your key names and hosts, obviously.

    • Wilker
      link
      fedilink
      31 year ago

      have at it!

      taken from Gitlab’s manual page for creating a key, but i wonder what else could be done to expand on it.

      #~/.gitconfig
      [includeIf "hasconfig:remote.*.url:https://gitlab.com/**"]
      path = /path/to/gitlab.gitconfig
      [includeIf "hasconfig:remote.*.url:https://github.com/**"]
      path = /path/to/github.gitconfig
      

      #example gitlab gitconfig from the included path
      [user]
      name = Your Name
      email = [email protected]
      signingkey = 0000999988887777
      
      [commit]
      gpgsign = true
      

      if all works well, Git should be able to automatically use the selected key depending on the repo’s stated remote server.