Github Deploy Key

Jim Kang
2 min readMar 3, 2022

Let’s say Micky Mouse use his github account on a server, and then next day he was fired from Disney, wouldn’t that be something if you’re taking over the deployment? This is why you need github deploy key — A key you use on server to do git stuff.

basically deploy key = server public ssh key

1. Generate SSH Key

We want to generate a new ssh key instead of using the default id_rsa because github doesn’t allow same key to be used twice. Maybe you have 2+ repo in same server, then sharing the same deploy key will not work. To generate new key, run the following:

DO NOT COPY AND PASTE FOLLOWING BLATANTLY

> cd ~/.ssh 
> ssh-keygen -t ed25519 -C "team-email@company.com" -f "REPO-NAME-HERE"

New public and private key will be generated inside ~/.ssh I am using repo-name as the key file name so that it’s better for me to extinguish.

2. Add Public Key to Github Repo

Navigate to your github repo and look under Settings > Deploy Keys. Find Add deploy key button and add the content your newly-generated-key.pub there.

3. Setup SSH Config

Now let’s match which repo use which private ssh key (repo <=> private key). If you don’t have ~/.ssh/config you can create one:

> touch ~/.ssh/config 
> chmod 600 ~/.ssh/config

--

--

Jim Kang

love writing bit sized programming memo, acoustic guitarist, proud daddy of 5 and great listener (to my kids)