How to use SSH Keys In Git

SSH keys provide a secure way to authenticate without needing to enter a password or token every time.

Step-by-Step Guide to Using SSH Keys:

Step 1: Generate an SSH Key

If you don’t already have an SSH key, you can generate one using the following command

ssh-keygen -t ed25519 -C "your_email@example.com"

Follow the prompts to save the key (default location is usually fine). You can set a passphrase for added security.

Step 2: Add the SSH Key to the SSH Agent

Start the SSH agent in the background and add your SSH key

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

Step 3: Add the SSH Key to Your GitHub Account

  • Copy the SSH key to your clipboard:
  • Go to GitHub and log into your account.
  • Click on your profile picture in the top-right corner and select “Settings”.
  • In the left sidebar, click on “SSH and GPG keys”.
  • Click “New SSH key”, give it a title, and paste your key into the “Key” field.
  • Click “Add SSH key”.

Step 4: Using SSH for Git Operations

Use the SSH URL for Git operations instead of the HTTPS URL.

git clone git@github.com:username/repository.git

How to Fix “Support for password authentication was removed.”?

With the increasing focus on security in software development and deployment, many platforms are moving away from less secure methods of authentication. GitHub, in particular, has deprecated password-based authentication for Git operations, encouraging users to adopt more secure methods such as personal access tokens (PATs) and SSH keys. If you’ve encountered the error “Support for password authentication was removed,” this article will help you transition to using personal access tokens or SSH keys for authentication.

Password authentication error occurs when attempting to perform Git operations (like git clone, git push, or git pull) using a username and password. GitHub has removed this method to enhance security and protect user accounts from unauthorized access.

There are various methods to fix password authentication problems which are as follows:

Table of Content

  • Using Personal Access Tokens (PATs)
  • Using SSH Keys

Similar Reads

Using Personal Access Tokens (PATs)

A personal access token is a secure way to authenticate with GitHub from the command line or other applications....

Using SSH Keys

SSH keys provide a secure way to authenticate without needing to enter a password or token every time....

Contact Us