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

      Sentry launches MCP monitoring tool

      August 14, 2025

      10 Benefits of Hiring a React.js Development Company (2025–2026 Edition)

      August 13, 2025

      From Line To Layout: How Past Experiences Shape Your Design Career

      August 13, 2025

      Hire React.js Developers in the US: How to Choose the Right Team for Your Needs

      August 13, 2025

      I’ve tested every Samsung Galaxy phone in 2025 – here’s the model I’d recommend on sale

      August 14, 2025

      Google Photos just put all its best editing tools a tap away – here’s the shortcut

      August 14, 2025

      Claude can teach you how to code now, and more – how to try it

      August 14, 2025

      One of the best work laptops I’ve tested has MacBook written all over it (but it’s even better)

      August 14, 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

      Controlling Execution Flow with Laravel’s Sleep Helper

      August 14, 2025
      Recent

      Controlling Execution Flow with Laravel’s Sleep Helper

      August 14, 2025

      Generate Secure Temporary Share Links for Files in Laravel

      August 14, 2025

      This Week in Laravel: Filament 4, Laravel Boost, and Junie Review

      August 14, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      KDE Plasma 6 on Wayland: the Payoff for Years of Plumbing

      August 14, 2025
      Recent

      KDE Plasma 6 on Wayland: the Payoff for Years of Plumbing

      August 14, 2025

      FOSS Weekly #25.33: Debian 13 Released, Torvalds vs RISC-V, Arch’s New Tool, GNOME Perfection and More Linux Stuff

      August 14, 2025

      Ultimate ChatGPT-5 Prompt Guide: 52 Ideas for Any Task

      August 14, 2025
    • 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:

       (type -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$out https://cli.github.com/packages/githubcli-archive-keyring.gpg 
           && cat $out | 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 
           && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | 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 enable it before using WSL.
       grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
       [error] WSL Interoperability is disabled. Please enable 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 in 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 set -h github.com git_protocol https
          ✓ Configured git protocol
          ! Authentication credentials saved in plain text
          ✓ Logged in as YOUR-GITHUB-USERNAME
          ! You were already logged in 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 ArticleKDE Plasma 6 on Wayland: the Payoff for Years of Plumbing
    Next Article How AI is Changing the Way We Code

    Related Posts

    Development

    Controlling Execution Flow with Laravel’s Sleep Helper

    August 14, 2025
    Development

    Generate Secure Temporary Share Links for Files in Laravel

    August 14, 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

    CodeSOD: The Variable Toggle

    News & Updates

    Microsoft Edge’s settings menu is now so big it can’t fit on a single screen

    News & Updates

    Kubernetes Networking: Services, Ingress and DNS Explained

    Learning Resources

    AWS machine learning supports Scuderia Ferrari HP pit stop analysis

    Machine Learning

    Highlights

    Development

    How Incremental Static Regeneration (ISR) Works in Next.js

    May 1, 2025

    When you build a website, you often have two main choices for how pages are…

    Langflow Under Attack: CISA Warns of Active Exploitation of CVE-2025-3248

    May 5, 2025

    CVE-2025-50489 – PHPGurukul Student Result Management System Session Hijacking Vulnerability

    July 28, 2025

    FBI, Ghana Authorities Bust $100 Million Romance Scam in Major International Extradition

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

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