Last active
August 10, 2023 13:34
-
-
Save agritheory/4422bd0abc61f873360eb3e164046a93 to your computer and use it in GitHub Desktop.
Add deploy key
This file contains 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 characters
# 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 |
~/.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
Git clone: