Setting up an SSH key on your Virtual Private Server (VPS) for GitHub not only enhances security but also simplifies the Git operations you perform. This guide will walk you through the process step by step.

STEP 1: GENERATE THE SSH KEY ON YOUR VPS
Execute the following command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This command will initiate the creation of a new SSH key. The -C flag is used to label the key with your email, aiding in identification.
STEP 2: DISPLAY AND COPY THE PUBLIC KEY
To view your public key, use:
cat ~/.ssh/id_rsa.pub
Copy the displayed key as you'll need it for GitHub.
STEP 3: ADD THE SSH KEY TO YOUR GITHUB ACCOUNT
- Navigate to your GitHub settings.
- Select "SSH and GPG keys" from the sidebar.
- Click the "New SSH key" button.
- Label your key (e.g., "VPS Server") and paste the copied public key into the "Key" field.
- Confirm by clicking "Add SSH key"
STEP 4: TEST THE CONNECTION
To ensure everything is set up correctly, test the connection with:
ssh -T git@github.com
A successful setup will display a message indicating successful authentication.
STEP 5: CONFIGURE GIT ON YOUR VPS
If you haven't already, set up Git with your details:
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
By following these steps, your VPS will use the SSH key for GitHub authentication, eliminating the need for username and password input during Git operations.
Developer proof standard
IsItDev tutorials in this cluster are being upgraded with terminal screenshots, measured benchmarks, and public GitHub repos. If you adapt this guide, document what you ran and link your repo — that is what earns trust with Google and other developers.
Cluster home: Self-Hosted Tools for Developers: Complete Guide


You must be logged in to post a comment.