This sccript is in two versions:
- Linux: github-ssh-setup.sh
- Windows+Git Bash: github-ssh-setup_OS_WINDOWS.sh
git clone https://github.com/martinandersen3d/github-ssh-key-setup.git
cd github-ssh-key-setup/
./github-ssh-setup.sh
Use this option if your are settings up your developer computer.
https://github.com/settings/keys
3B. Add Keys on a git repository (Computer will have access ONLY on the repositories, where you add the key):
Use this option if your have a server, that needs access to ONE or more private/public repositories.
- Go to the repository you want the server to access.
- Go into repository > Settings
- Deploy keys
- Add Deploy key
Todo:
- Currently it overwrites the file in c:\users\$USER\.ssh\config, if you have any data there, make a backup before you run the script
- Replace all github descriptions with Azure Devops descriptions
Note: For some stupid reason Microsoft needs TWO domains to make the SSH work for Azure, and not one domain like everyone else.
Example of config file: C:\Users\MyUsername.ssh\config
Host ssh.dev.azure.com
PubkeyAcceptedKeyTypes=ssh-rsa
HostName ssh.dev.azure.com
IdentityFile C:\Users\MyUsername\.ssh\azure_rsa
IdentitiesOnly yes
AddKeysToAgent yes
PasswordAuthentication=no
User git
Host vs-ssh.visualstudio.com
IdentityFile C:\Users\MyUsername\.ssh\azure_rsa
IdentitiesOnly yes
You should have a config file in: Windows:
C:\Users\<username>\.ssh\config
Linux:
~/.ssh/config
If you have mulitple repos from github you want to add Deploy keys to, you might need to edit the config file, like this: Windows example:
host github_superman
HostName github.com
IdentityFile C:/Users/username/.ssh/github_superman_id_rsa
User git
host github_catwoman
HostName github.com
IdentityFile C:/Users/username/.ssh/github_catwoman_id_rsa
User git
And your git clone
, command will need to be changed:
git clone git@github_superman:githubusername/repo.git
git clone git@github_catwoman:githubusername/repo.git