Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to Set Up GitHub CLI on WSL2

    How to Set Up GitHub CLI on WSL2

    August 14, 2025

    Recently, I set up WSL2 and Ubuntu on my Windows 11 to work on some open-source projects. Since I also maintain these projects, I installed GitHub CLI to ease my workflow. I successfully installed the GitHub CLI, but failed to authenticate it.

    The error message failed to authenticate via web browser: Too many requests have been made in the same timeframe. (slow_down) appeared on my terminal, while on the web browser, it indicated that the authentication was successful.

    A message says "Congratulations, you're all set," marking GitHub CLI authentication is successful

    I googled and found some workarounds that I tried, but only one worked like a charm!

    After finally solving the tricky authentication issue for GitHub CLI on WSL2, I’ve put together this guide. It’s a complete walkthrough for a solution that works, covering everything from a smooth installation to ongoing management.

    Table of Contents

    • Prerequisites

    • How to Install GitHub CLI on WSL2

    • How to Authenticate GitHub CLI on WSL2 with Your GitHub Account

    • How to Upgrade GitHub CLI on WSL2

    • How to Uninstall GitHub CLI on WSL2

    • How to Revoke GitHub CLI Access on GitHub

    • Final Words

    Prerequisites

    Before getting started, ensure that you have these installed on your Windows machine:

    • WSL2

    • A Linux distro

    • Windows PowerShell

    • Windows Terminal (optional)

    To follow the instructions in this article, you can use Windows PowerShell terminal as an administrator.

    Alternatively, if you have Windows Terminal installed, you can use the Linux terminal by clicking the ‘down arrow’ icon at the top and selecting the distro.

    Dropdown menu at Windows Terminal

    How to Install GitHub CLI on WSL2

    You can use the installation process described here if you use Ubuntu, Debian, or Raspberry Pi OS (apt) distros. For other distros other than those mentioned here, you can walk through the installation process that’s available on the GitHub CLI official docs.

    To install GitHub CLI in WSL2:

    1. Run this command:

       (<span class="hljs-built_in">type</span> -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) 
           && sudo mkdir -p -m 755 /etc/apt/keyrings 
           && out=$(mktemp) && wget -nv -O<span class="hljs-variable">$out</span> https://cli.github.com/packages/githubcli-archive-keyring.gpg 
           && cat <span class="hljs-variable">$out</span> | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null 
           && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg 
           && sudo mkdir -p -m 755 /etc/apt/sources.list.d 
           && <span class="hljs-built_in">echo</span> <span class="hljs-string">"deb [arch=<span class="hljs-subst">$(dpkg --print-architecture)</span> signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main"</span> | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null 
           && sudo apt update 
           && sudo apt install gh -y
      
    2. Type your Linux password when you get prompted.

    3. Ensure the GitHub CLI is installed by running gh --version command. If the installation is successful, you should see something like this in your terminal:

       gh version 2.76.2 (2025-07-30)
       https://github.com/cli/cli/releases/tag/v2.76.2
      

    How to Authenticate GitHub CLI on WSL2 with Your GitHub Account

    Before you can use GitHub CLI, you must first authenticate it. You will get an HTTP 401: Bad credentials (https://api.github.com/graphql) error message if you run any GitHub CLI command without authenticating.

    To authenticate GitHub CLI with your GitHub account:

    1. Run the gh auth login command in your terminal.

    2. You will receive several prompts, and you need to choose the methods you prefer. Here’s what I selected in each prompt:

       ? Where do you use GitHub? GitHub.com
       ? What is your preferred protocol for Git operations on this host? HTTPS
       ? How would you like to authenticate GitHub CLI? Login with a web browser
      

      After answering all prompts, you should get the message to copy a one-time code as shown below. You don’t need to copy the code at this point.

       ! First copy your one-time code: XXXX—XXXX
      
    3. Press ‘Enter’. It automatically opens the “Device Activation” page on your browser.

    4. Click the green ‘Continue’ button.

      GitHub Device Activation page on a browser

      GitHub should ask you to enter the code displayed on your terminal, as shown in the screenshot below. But here’s the trick! Don’t paste any code, and don’t close the browser. Let’s first get back to your terminal.

      GitHub Device Activation page on a browser

      Now you might get this error message on your terminal:

       grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
       WSL Interopability is disabled. Please <span class="hljs-built_in">enable</span> it before using WSL.
       grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
       [error] WSL Interoperability is disabled. Please <span class="hljs-built_in">enable</span> it before using WSL.
      
    5. Press Ctrl + C to stop the process if it’s still running, or let it stop by itself. Once it’s stopped, you should see this message:

       failed to authenticate via web browser: Too many requests have been made <span class="hljs-keyword">in</span> the same timeframe. (slow_down)
      
    6. Run the gh auth login command again and repeat the process to select the methods of your choice. This time, when it asks you to press ‘Enter’, don’t press it.

    7. Copy the latest code and return to the “Device Activation” page that you left open in your browser.

    8. Paste the code that you copied and click the green ‘Continue’ button.

    9. Click the green ‘Authorize github’ button after GitHub redirects you to the “Authorize GitHub CLI” page. You should now see the message “Congratulations, you’re all set!”

    10. Get back to your terminal and press ‘Enter’. Doing so triggers these actions:

      • It automatically opens a new “Device Activation” page in your browser. You can safely ignore this.

      • In the terminal, you first see the error message as in step 4. Don’t do anything and wait for a little bit. Then, you get:

          ✓ Authentication complete.
          - gh config <span class="hljs-built_in">set</span> -h github.com git_protocol https
          ✓ Configured git protocol
          ! Authentication credentials saved <span class="hljs-keyword">in</span> plain text
          ✓ Logged <span class="hljs-keyword">in</span> as YOUR-GITHUB-USERNAME
          ! You were already logged <span class="hljs-keyword">in</span> to this account
        

    And GitHub CLI is now successfully authenticated!

    Credit goes to username “ikeyan” on GitHub for their GitHub CLI authentication solution!

    How to Upgrade GitHub CLI on WSL2

    It’s always a good practice to regularly check for package and dependency updates, and upgrade to the newest version when it’s available — this includes GitHub CLI. To check for updates and upgrade the version of GitHub CLI:

    1. Run the sudo apt update command in your terminal. This command fetches the list of available updates.

    2. Type your Linux password when you get prompted.

    3. If you need to upgrade your GitHub CLI, run sudo apt install gh. This command installs the newest version of GitHub CLI.

    4. Type your Linux password when you get prompted.

    Now your GitHub CLI has the newest version.

    How to Uninstall GitHub CLI on WSL2

    If one day you feel like you don’t need to use GitHub CLI anymore, you can uninstall it by following these steps:

    1. Run the sudo apt remove gh command in your terminal.

    2. Type your Linux password when you get prompted.

    3. Press ‘Y’ to continue the uninstall process.

    GitHub CLI is now uninstalled from your WSL environment.

    How to Revoke GitHub CLI Access on GitHub

    After uninstalling the GitHub CLI, you might think your account access is gone, but it’s not. The authentication you granted is still active. If you don’t plan on using the CLI again, it’s a good practice to revoke this access.

    Here’s how to do it directly from your GitHub account:

    1. On your GitHub account, click your profile picture on the top right and click ‘Settings’.

      Settings option on dropdown menu at GitHub

      1. On the left side bar, find ‘Integrations’ and click ‘Applications’.

        Applications tab in the Integrations settings on GitHub

      2. Click the ‘Authorized OAuth Apps’ tab on top.

        Authorized OAuth Apps tab on GitHub

      3. Find GitHub CLI and click the ‘three dots’ icon next to it.

      4. Click ‘Revoke’.

        Revoke option on GitHub to revoke an authorized OAuth apps

      5. Confirm it by clicking the ‘I understand, revoke access’ button.

    Now, GitHub CLI doesn’t have access to your GitHub account.


    Final Words

    🖼️ Credit cover image: undraw.co

    Thank you for reading! Last, you can find me on X and LinkedIn. Let’s connect! 😊

    Source: freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleCISA Adds Two N-able N-central Flaws to Known Exploited Vulnerabilities Catalog
    Next Article How AI is Changing the Way We Code

    Related Posts

    Development

    Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

    September 28, 2025
    Development

    Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

    September 28, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Can LLMs do accounting?

    Web Development

    Building a Seamless Live Streaming App with React Native📺✨

    Web Development

    Fortinet OS Command Injection Vulnerability Lets Attackers Execute Unauthorised Code on FortiAnalyzer-Cloud

    Security

    Meet LangGraph Multi-Agent Swarm: A Python Library for Creating Swarm-Style Multi-Agent Systems Using LangGraph

    Machine Learning

    Highlights

    Development

    U.S. Data Breach Costs Rise as Global Average Falls

    July 31, 2025

    Data breaches in the U.S. are getting more costly even as they’re getting cheaper in…

    Microsoft Defender for Identity Flaw (CVE-2025-26685) Allows Unauthenticated Privilege Escalation

    June 15, 2025

    Progress adds AI coding assistance to Telerik and Kendo UI libraries

    September 19, 2025

    Multi-Dimensional Vector Support in CocoIndex

    August 11, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.