Skip to content

Instantly share code, notes, and snippets.

@viniciusCamargo
Forked from jexchan/multiple_ssh_setting.md
Last active August 3, 2023 00:01
Show Gist options
  • Save viniciusCamargo/b60677babe91ca65f7580a6c233334c9 to your computer and use it in GitHub Desktop.
Save viniciusCamargo/b60677babe91ca65f7580a6c233334c9 to your computer and use it in GitHub Desktop.
Multiple SSH keys for different Github accounts

github multiple keys

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/{private_key}
$ git clone git@{alias}:{github_user}/{repo}.git

~/.ssh/config

Host github.com-{alias}
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/{private_key}

{repo}/.git/config

[remote "origin"]
    url = [email protected]{alias}:{github_user}/{repo}.git
    fetch = +refs/heads/*:refs/remotes/origin/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment