06 [Install guides](https://logicpacks.io/install) · 15 min

# Set up GitHub and the gh CLI

GitHub stores your projects online. The `gh` command logs you in from the terminal, and an SSH key lets git push without typing a password.

Roman Urdu: GitHub pe aap ka code online save hota ha. gh se terminal se login hota ha aur SSH key se baar baar password nahi dalna parta.

**Cost:** Free account: unlimited public and private repositories and 2,000 CI/CD minutes a month (github.com/pricing, 2026-12-05). gh is free and open source.

[Windows](#windows) · [macOS](#macos) · [Linux (Ubuntu/Debian)](#linux) · [Android (Termux)](#android)

## Windows

1.  Create a free account on github.com ([how](https://docs.github.com/en/get-started/start-your-journey/creating-an-account-on-github)). GitHub requires two-factor authentication (2FA) for accounts that contribute code, such as making releases; you get an email and 45 days to turn it on. Set it up early with an authenticator app (TOTP), the recommended method.
2.  Install gh in PowerShell:
    
    ```sh
    winget install --id GitHub.cli --source winget
    ```
    
3.  Open a **new** terminal window (a new tab is not enough), then log in. Choose **GitHub.com**, **SSH**, and say yes when it offers to create and upload an SSH key:
    
    ```sh
    gh auth login
    ```
    
4.  Already have a key, or skipped that step? Make one and upload it yourself (press Enter to accept the default file):
    
    ```sh
    ssh-keygen -t ed25519 -C "you@example.com"
    ```
    
    ```sh
    gh ssh-key add $HOME\.ssh\id_ed25519.pub --title "My laptop"
    ```
    

## macOS

1.  Create a free account on github.com ([how](https://docs.github.com/en/get-started/start-your-journey/creating-an-account-on-github)) and turn on 2FA with an authenticator app (required for contributors, see the Windows tab).
2.  Install gh with Homebrew:
    
    ```sh
    brew install gh
    ```
    
3.  Log in. Choose **GitHub.com**, **SSH**, and let it create and upload an SSH key:
    
    ```sh
    gh auth login
    ```
    
4.  Or make and upload a key yourself:
    
    ```sh
    ssh-keygen -t ed25519 -C "you@example.com"
    ```
    
    ```sh
    gh ssh-key add ~/.ssh/id_ed25519.pub --title "My laptop"
    ```
    

## Linux (Ubuntu/Debian)

1.  Create a free account on github.com ([how](https://docs.github.com/en/get-started/start-your-journey/creating-an-account-on-github)) and turn on 2FA with an authenticator app.
2.  Install gh from GitHub's official apt repository (one long command, copy it whole):
    
    ```sh
    (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
    ```
    
3.  Fedora (DNF5):
    
    ```sh
    sudo dnf install dnf5-plugins
    ```
    
    ```sh
    sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo
    ```
    
    ```sh
    sudo dnf install gh
    ```
    
4.  Log in. Choose **GitHub.com**, **SSH**, and let it create and upload an SSH key:
    
    ```sh
    gh auth login
    ```
    
5.  Or make and upload a key yourself:
    
    ```sh
    ssh-keygen -t ed25519 -C "you@example.com"
    ```
    
    ```sh
    gh ssh-key add ~/.ssh/id_ed25519.pub --title "My laptop"
    ```
    

## Android (Termux)

1.  gh in Termux is a community package, not maintained by the GitHub CLI team, but it works for login and repos:
    
    ```sh
    pkg install gh openssh
    ```
    
2.  Log in. Choose **SSH** and let it create and upload a key:
    
    ```sh
    gh auth login
    ```
    

## Check it worked

```sh
gh auth status
```

```sh
ssh -T git@github.com
```

gh says you are logged in; ssh prints "Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access."

## Common errors

`gh` is not recognized right after winget (Windows)

Open a new terminal window, not just a new tab.

`ssh -T` asks "Are you sure you want to continue connecting (yes/no)?"

Normal the first time. Type `yes` and press Enter.

`git@github.com: Permission denied (publickey)`

Your key is not on GitHub yet. Run `gh ssh-key add` with your `.pub` file (see above), then try `ssh -T git@github.com` again.

`gh ssh-key add` says it needs the "admin:public\_key" scope

Run `gh auth refresh -h github.com -s admin:public_key`, approve in the browser, then run the add command again.

Locked out after the 2FA deadline

Sign in and finish 2FA setup to get access back. Save the recovery codes GitHub shows you somewhere safe.

## Official docs

-   [GitHub Docs: Create an account](https://docs.github.com/en/get-started/start-your-journey/creating-an-account-on-github)
-   [GitHub: Pricing](https://github.com/pricing)
-   [GitHub Docs: Mandatory 2FA](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/about-mandatory-two-factor-authentication)
-   [gh: Install on Windows](https://github.com/cli/cli/blob/trunk/docs/install_windows.md)
-   [gh: Install on macOS](https://github.com/cli/cli/blob/trunk/docs/install_macos.md)
-   [gh: Install on Linux](https://github.com/cli/cli/blob/trunk/docs/install_linux.md)
-   [gh manual: gh auth login](https://cli.github.com/manual/gh_auth_login)
-   [gh manual: gh ssh-key add](https://cli.github.com/manual/gh_ssh-key_add)
-   [GitHub Docs: Generate an SSH key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
-   [GitHub Docs: Test your SSH connection](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection)

Checked against these pages on 2026-12-05. Tools change: if a step differs, the official page wins.

[Install guides : All guides](https://logicpacks.io/install) [Next : Install Claude Code](https://logicpacks.io/install/claude-code)

---

Canonical URL: https://logicpacks.io/install/github

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](https://logicpacks.io/llms.txt). Plain facts: [/about.md](https://logicpacks.io/about.md). Safety: [/safety.md](https://logicpacks.io/safety.md).
