HOW TO GENERATE AN SSH KEY FOR GITHUB ON A VPS

by

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.

 SSH KEY FOR GITHUB

STEP 1: GENERATE THE SSH KEY ON YOUR VPS

Execute the following command:

ssh-keygen -t rsa -b 4096 -C “[email protected]

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 [email protected]

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 “[email protected]

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.

all_in_one_marketing_tool