Last active
March 28, 2024 19:32
-
-
Save cognivator/91e4f8cbf41cf7fe1b9a31f4d0ec56c7 to your computer and use it in GitHub Desktop.
Revisions
-
cognivator revised this gist
Mar 28, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ There are plenty of references for generating and using SSH keys on MacOS. Googl ### Solution The nuggets of goodness I found describe how to properly use `~/.ssh/config` - ([here](https://gist.github.com/Jonalogy/54091c98946cfe4f8cdab2bea79430f9), [here](https://medium.nextlevelswift.com/creating-two-ssh-keys-on-mac-for-two-different-github-accounts-b2456734e8f1), [here](https://pratapsharma.io/github-miltiple-key), [ here](https://gist.github.com/jmcaldera/e445ff878c81e16d0c19b4049f009703)... +[many more](https://www.google.com/search?q=macos+ssh+github+multiple+keys)). The key is actually _**using**_ the resulting `Host` aliases! Go figure, huh? :facepalm: -
cognivator revised this gist
Mar 28, 2024 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ ### Situation There are plenty of references for generating and using SSH keys on MacOS. Google for answers and they're everywhere. What is less obvious is how to use multiple SSH keys, especially for the same host, e.g. GitHub. I had multiple SSH keys and a `~/.ssh/config` file, but certain of the credentials weren't being found. ### Solution The nuggets of goodness I found describe how to properly use `~/.ssh/config` - ([here](https://gist.github.com/Jonalogy/54091c98946cfe4f8cdab2bea79430f9), [here](https://medium.nextlevelswift.com/creating-two-ssh-keys-on-mac-for-two-different-github-accounts-b2456734e8f1), [here](https://pratapsharma.io/github-miltiple-key), [ here](https://gist.github.com/jmcaldera/e445ff878c81e16d0c19b4049f009703)... +[many more](https://www.google.com/search?q=macos+ssh+github+multiple+keys)). The key bit of information to make everything work is to actually _**use**_ the resulting `Host` aliases! Go figure, huh? :facepalm: ### Example: Github - SourceTree In concrete terms, and skipping all the SSH generation tasks — references abound — the key insight in code is... @@ -27,5 +27,5 @@ Then anywhere you would normally reference the url host directly... don't. Use t - NO: `git@`**github.com**`:username/repository.git` - YES: `git@`**github-alias-x**`:username/repository.git` It's magical. :magic_wand: -
cognivator created this gist
Mar 28, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ ### Situation There are plenty of references for generating and using SSH keys on MacOS. Google for answers and they're everywhere. What is harder to do is use multiple SSH keys, especially for the same host, e.g. GitHub. I had multiple SSH keys, and a `~/.ssh/config` file, but certain of the credentials weren't being found. ### Solution The nuggets of goodness I found describe how to properly use `~/.ssh/config` - ([here](https://gist.github.com/Jonalogy/54091c98946cfe4f8cdab2bea79430f9), [here](https://medium.nextlevelswift.com/creating-two-ssh-keys-on-mac-for-two-different-github-accounts-b2456734e8f1), [here](https://pratapsharma.io/github-miltiple-key), [ here](https://gist.github.com/jmcaldera/e445ff878c81e16d0c19b4049f009703)...). The key bit of information to make everything work is to actually _**use**_ the resulting `Host` aliases! Go figure, huh? ### Example: Github - SourceTree In concrete terms, and skipping all the SSH generation tasks — references abound — the key insight in code is... Add the host-key mappings to `~/.ssh/config`, ``` Host github-alias-1 HostName github.com ... IdentifyFile ~/.ssh/key1 Host github-alias-2 HostName github.com ... IdentifyFile ~/.ssh/key2 ``` Then anywhere you would normally reference the url host directly... don't. Use the `Host` alias from the config file instead, - NO: `git@`**github.com**`:username/repository.git` - YES: `git@`**github-alias-x**`:username/repository.git` It's magical.