Deployment Workflow - humanbit-dev-org/templates GitHub Wiki
Here's a step-by-step SSH authentication guide for GitHub based on our setup.
Anyone using the same system user (e.g., root
) will have access to the SSH key and GitHub authentication.
GitHub SSH Authentication Guide
This guide explains how to set up SSH authentication for GitHub on a server.
Step 1: Check for an Existing SSH Key
Run the following command to check if an SSH key already exists:
ls -l ~/.ssh/id_*
If you see files like id_ed25519
and id_ed25519.pub
, an SSH key already exists. If not, generate a new one.
Step 2: Generate a New SSH Key (If Needed)
If no SSH key is found, create one with:
ssh-keygen -t ed25519 -C "[email protected]"
- Press Enter to accept the default file location (
~/.ssh/id_ed25519
). - Set a passphrase (optional).
Step 3: Add the SSH Key to GitHub
Display the public key:
cat ~/.ssh/id_ed25519.pub
Copy the output and add it to GitHub:
- Go to GitHub → Settings → SSH and GPG keys.
- Click New SSH key.
- Title: Enter a name like
Server SSH Key
. - Key type: Select
Authentication Key
. - Paste the copied public key.
- Click Add SSH key.
Step 4: Test the SSH Connection
Verify the SSH key is working:
ssh -T [email protected]
If successful, you'll see:
Hi <your-username>! You've successfully authenticated, but GitHub does not provide shell access.
Step 5: Configure Git to Use SSH
Check if the remote URL is set to HTTPS:
git remote -v
If you see a URL starting with https://
, switch to SSH:
git remote set-url origin [email protected]:org-name/repo-name.git
Verify the update:
git remote -v
You should now see:
[email protected]:org-name/repo-name.git (fetch)
[email protected]:org-name/repo-name.git (push)
Step 6: Pull the Latest Changes
Now, fetch the latest updates from GitHub:
git pull origin main
(Replace main
with the actual branch name if different.)
git pull
will work as well, as long as you're already on the correct branch and the remote (origin) is set up properly.
Step 7: Verify SSH Access to All Organization Repositories
If the SSH key is under the user who owns the organization, it should have access to all repos the user has access to.
To confirm, try cloning a private repo from the org:
git clone [email protected]:org-name/repo-name.git
If cloning succeeds, SSH authentication is fully set up.
This guide ensures anyone can log in with SSH, authenticate GitHub, and pull updates on this server.