There are multiple ways to login to GitHub in our devices - via Dedicated Applications and Clients (GitHub Desktop, GitHub Mobile), via Web Browser, via Terminal.

In this guide I will help you login via the Terminal.

Pre-requisites

  1. GitHub Account (Please create GitHub account if you still don’t have one.)
  2. Terminal Application (Termux, Terminal, Tabby)

Install GitHub

Copy and paste the command below in your terminal. This installs GitHub CLI.

sudo apt update
sudo apt install gh

Note: If you are using other distro’s / package managers, please refer to the official documentation here.

🍰 Easy Mode - Browser Method

  1. In the Terminal, type gh auth login.
  2. You will be having the following prompts below. Just choose the options highlighted after the prompt.
  3. Remember the 8-character code provided and click enter to open GitHub in the browser.
  4. Enter the number and authenticate via your preferred method.
  5. Once done you will get the following response response.
  6. 👍 You are now Logged In!

🪨 Hard Mode - SSH & Personal Access Token (P.A.T.) Method

  1. In the terminal, type gh auth login
  2. You will have the following prompt, in the second question choose SSH.
  3. You will be asked to generate your SSH Public Key to your GitHub Account. Enter a passphrase and it should be generated automatically once you hit enter.
  4. When asked how you would like to authenticate use Paste an authentication token

Generate a Classic Token

  1. Go to this link: https://github.com/settings/tokens
  2. Choose between ‘Fine-Grained Token’ or ‘Classic Token’ (for this tutorial I will use Classic)
  3. Add Note (Note: be descriptive on where this would be used for easier management)
  4. Set Expiration Date
    • It is highly-recommended to set an expiration date specially when using on devices you do not own to prevent unwanted access.
  5. Select all options containing repo, repo:org, and admin:public_key
  6. Click Generate Token
  7. Copy the Key and paste it in the terminal.
  8. 👍 You are now Logged In!

🆎Differences

Weigh in the methods according to your needs and risks associated. See the table below for a quick overview.

Login to GitHub🪨 Hard Mode - SSH & P.A.T.
FeatureWeb Browser AuthenticationPersonal Access Token (PAT) Authentication
MethodInteractive browser-based loginManual token generation, then use in place of password
Use CaseInteractive use on local machinesAutomation, headless environments, CI/CD
ConvenienceUser-friendly for initial setupRequires manual PAT generation and management
SecurityToken handled by system credential storeRequires careful handling and secure storage of the PAT
ControlBroad access based on user permissionsGranular control over permissions via token scopes

📜 References

[1]: Managing your personal access tokens. (n.d.). GitHub Docs. Retrieved September 7, 2025, from https://docs-internal.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

Please feel free to comment down below for any issues and suggestions.