SSH Key Management for GitHub and Azure DevOps

1 min read

A Step-by-Step Guide
Create SSH Directory
mkdir -p ~/.ssh/github
mkdir -p ~/.ssh/devops
Create SSH Keys
SSH Key for GitHub
ssh-keygen -t rsa -b 4096 -f ~/.ssh/github/${yourAccountName}/id_rsa -C "${yourEmail}"
SSH Key for Azure DevOps
ssh-keygen -t rsa -b 4096 -f ~/.ssh/devops/${yourOrganizationName}/id_rsa -C "${yourEmail}"
Create ~/.ssh/config
vi ~/.ssh/config
Host github-${yourAccountName}.com
HostName github.com
User git
AddKeysToAgent yes
IdentitiesOnly yes
UseKeychain yes
IdentityFile ~/.ssh/github/${yourAccountName}/id_rsa
Host devops-${yourOrganizationName}.com
HostName ssh.dev.azure.com
User git
AddKeysToAgent yes
IdentitiesOnly yes
UseKeychain yes
IdentityFile ~/.ssh/devops/${yourOrganizationName}/id_rsa
Copy and Paste Public Key to GitHub
pbcopy < ~/.ssh/github/${yourAccountName}/id_rsa.pub
Copy and Paste Public Key to Azure DevOps
pbcopy < ~/.ssh/devops/${yourOrganizationName}/id_rsa.pub
Clone Repository
GitHub
git clone git@github-${yourAccountName}.com:${yourAccountName}/${yourProjectName}.git
GitHub
git clone git@devops-${yourOrganizationName}.com:${yourOrganizationName}/${yourProjectName}.git
Please make sure to replace ${yourAccountName}
, ${yourOrganizationName}
, ${yourEmail}
, and ${yourProjectName}
with your actual values before using this script.
0
Subscribe to my newsletter
Read articles from ochairo's memo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

ochairo's memo
ochairo's memo
Developer based in Tokyo, Japan.