DEV Community

Harrsh Patel
Harrsh Patel

Posted on

GitHub with SSH

Ever wondered how to work with the GitHub account associated with a different email address than the one set-up in your machine? We can do it with SSH Key.

In this article, we will see how to set up a GitHub repository with SSH.

Step 1 - Create an SSH Key

ssh-keygen -t ed25519 -C "<your email address>"
Enter fullscreen mode Exit fullscreen mode

Step 2 - Copy the SSH Key

clip < <path of the ssh key>
Enter fullscreen mode Exit fullscreen mode

Step 3 - Add SSH key to the GitHub account


Step 4 - Check if the SSH Key is validated

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

Step 5 - Link the GitHub repo to the SSH Key

git remote set-url origin git@github.com:<your username>/<repository name>.git
Enter fullscreen mode Exit fullscreen mode

Step 6 (Optional) - Set git username and email

git config user.email "<your email address>"
git config user.name "<your name>"
Enter fullscreen mode Exit fullscreen mode

You can now perform the Git operations for your repository.

Top comments (0)