Published on, Time to read
🕒 3 min read

Pushing to Github/GitLab/GitBucket using SSH Keys


Pushing to Github/GitLab/GitBucket using SSH Keys

Photo by Michael Dziedzic on Unsplash

As the days of the username and password authentication for pushing to GitHub repositories have depreciated, there is a need for a new method to authenticate users using git while pushing data. The use of SSH keys can come to the rescue in this situation. In this article, I will show you how to do this.

Steps to setup authentication using SSH key :

1. Check GIT.

Make sure that you have git installed on your computer.

2. Create a repo.

Make sure there is at least one file in it (even just the

3. Generate an SSH key pair (private/public):

You can do this by using the following command.

    ssh-keygen -t rsa -C ""

or by using an even better method.

    ssh-keygen -t rsa -b 4096 -C ""

4. Copy the contents of the public SSH key

In order to copy the content of the SSH key file that you have created. Do the following steps :

In macOS:

    pbcopy < ~/.ssh/

GNU/Linux (requires the xclip package):

    xclip -sel clip < ~/.ssh/

Windows Command Line:

    type %userprofile%\.ssh\ | clip

Git Bash on Windows / Windows PowerShell:

    cat ~/.ssh/ | clip

or of course copy it via your favorite editor, cat, or whatever suits your needs :)

Here is the file that stores your public key. You can rename it if you want.

5. Copy the public SSH key to GitHub

Copy the contents of your SSH keys to your GitHub account settings (

  1. Go to settings from your account.

  1. Click on SSH and GPG keys.

  1. Click on add new SSH key.

  1. Copy the contents of the file this case) that you have created and paste it into the key box and also insert a suitable title. Then click add SSH key.

5. Test the SSH key:

To tesh, the SSH key that you have generated is valid perform the command as below.

    ssh -T

Change directory into the local clone of your repository (if you’re not already there) and run:

    git remote set-url origin

Now try editing a file (try the README) and then do:

    git add -A
    git commit -am "Update"
    git push

You should not be asked for a username or password. If it works, your SSH key is correctly configured.

I hope that this article has helped you solve your authentication problems. Please do consider clapping for me if you find this article useful. Subscribe for more helpful articles.