May 3, 2021

309 words 2 mins read

HowTo - Github credential helper for Linux

HowTo - Github credential helper for Linux

Git for Windows provides a nice option to store credentials - Windows Credential store. Unfortunately this option is not available on Linux. What can be used instead?

First of all, you can connect to Git Server via SSH - it will work on both Linux and Windows in the same way. However, I personally prefer using HTTPS, so let’s see what we can do with it.

Option 1: connect with login and password

The default option is to connect with login and password. You can provide it on each connection to git remote or use git cache to store the password during current session.

The problem with using login and password on Github is that this method is deprecated and you will most likely receive the following email each time you use this method:

Hi @user,

You recently used a password to access the repository at user/repository with git using git/2.27.0.

Basic authentication using a password to Git is deprecated and will soon no longer work.

Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.

Thanks, The GitHub Team

Option 2: use Github CLI

Luckily, Github provides a reliable option for authentication - Github CLI.

You can find instructions for your distribution here: Github CLI installation instructions

After you installed Github CLI, connect to your Github account with the following command:

gh auth login

Select authentication methods. Your authentication code will be displayed in command line. You will need it on next step.

GitHub CLI authentication

Then you will be then redirected to the browser for authentication. Enter your credentials and then enter your authentication code from command line.

GitHub CLI device authentication

Then you have to authorize Github CLI to access your data:

GitHub CLI grant access

And that’s it! Now you are authorized in Github and can use git client to work with your git repository hosted on Github.


Image credits: