Github Deploy Key - orleanski/dotfiles GitHub Wiki
What / Why
Deploy key is a SSH key set in your repo to grant client read-only (as well as r/w, if you want) access to your repo.
As the name says, its primary function is to be used in the deploy process in replace of username/password, where only read access is needed. Therefore keep the repo safe from the attack, in case the server side is fallen.
How to
-
Generate a ssh key
run
ssh-keygen -t rsa -b 4096 -C "[email protected]", leave the password empty as you want the deploy process keyboard-less.after the generation, file
id_rsaandid_rsa.pubcan be found under.sshfolder. -
add ssh key to repo's "Deploy keys" setting
cat .ssh/id_rsa.pub -
Setup the git ssh key on the client machine
Git normally use the ssh key found in
~/.ssh/id_rsaYou can test the connection by:
sudo -u {user} ssh -T [email protected]*You might need to grant Github's key to known hosts.
If everything went well, you can see:
Hi {user}! You've successfully authenticated, but GitHub does not provide shell access.Then you are all set!
Attention: make sure your repo url use git protocol not http, which means use
[email protected]:{user}/{repo}.gitnot
https://github.com/{user}/{repo}.git
*Using multiple deploy key with different repo on the same machine
You can use /.ssh/config file to config different ssh key for different repo. For detail, please follow the instruction in Ref.3 below.