Skip to content

Instantly share code, notes, and snippets.

@agritheory
Last active August 10, 2023 13:34
Show Gist options
  • Save agritheory/4422bd0abc61f873360eb3e164046a93 to your computer and use it in GitHub Desktop.
Save agritheory/4422bd0abc61f873360eb3e164046a93 to your computer and use it in GitHub Desktop.
Add deploy key
# on local machine generate public and private keys
ssh-keygen -t ed25519
$ Generating public/private ed25519 key pair.
$ Enter file in which to save the key (/home/tyler/.ssh/id_ed25519): deploy_key
# add deploy_key.pub to github deploy keys via UI
# add both keys to server
# modify permissions
chmod 700 ~/.ssh
chmod 600 ~/.ssh/deploy_key
chmod 644 ~/.ssh/deploy_key.pub
# test connection to github
ssh -i "~/.ssh/deploy_key" git@github.com
# change from https to ssh
git remote set-url upstream ssh://git@github.com:user/repo.git
# add config to ~/.ssh/config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/deploy_key
IdentitiesOnly yes
# to configure a second private repo:
Host primary.github.com
HostName github.com
User git
IdentityFile ~/.ssh/deploy_key
IdentitiesOnly yes
Host secondary.github.com
HostName github.com
User git
IdentityFile ~/.ssh/secondary_deploy
IdentitiesOnly yes
@agritheory
Copy link
Author

Git clone:

git clone git@secondary.github.com:secondary/secondary.git

bench get-app secondary git@secondary.github.com:secondary/secondary.git

@agritheory
Copy link
Author

~/.ssh/authorized_keys and ~/.ssh/config should both have 700 permissions: chmod 700 authorized_keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment