Installing & Authenticating the GitHub CLI (gh) for GHES

Installing & Authenticating the GitHub CLI (gh) for GHES

A how-to for connecting the GitHub CLI to our GitHub Enterprise Server (GHES) instance at github.austin.utexas.edu.

Audience: Users with moderate-to-advanced technical knowledge on macOS or Windows.
Goal: Install gh and authenticate it against our enterprise host so git and gh commands work against github.austin.utexas.edu.


Prerequisites

  • An account on github.austin.utexas.edu.

  • Network access to the GHES instance. This requires the UT VPN (or an on-campus connection).

  •  

    • macOS: Terminal, iTerm2, etc.

    • Windows: PowerShell, Windows Terminal, or Git Bash.


1. Install gh

macOS (Homebrew)

brew install gh

Verify:

gh --version

No Homebrew? Install it from brew.sh, then run the command above.

Windows

Pick one of the following.

winget (recommended, built into Windows 10/11):

winget install --id GitHub.cli

Scoop:

scoop install gh

Chocolatey:

choco install gh

After installing, open a new terminal window (so PATH updates take effect) and verify:

gh --version

2. Authenticate to github.austin.utexas.edu

The key detail for enterprise is the --hostname flag. Without it, gh defaults to the public github.com. Point it at our GHES host instead.

Interactive login (recommended)

gh auth login --hostname github.austin.utexas.edu

You'll be prompted through a short wizard:

  1. Protocol for Git operations

    HTTPS

    SSH

    • Choosing HTTPS lets gh also act as your Git credential helper.

  2. Authenticate Git with your GitHub credentials?Yes (if prompted).

  3. How would you like to authenticate?

    • Login with a web browsergh shows a one-time code; press Enter, paste the code into the browser page that opens, and approve.

    • Paste an authentication token — supply a Personal Access Token (see below).

Verify

gh auth status --hostname github.austin.utexas.edu

You should see a line confirming you're logged in to github.austin.utexas.edu as your user.


3. Token authentication (alternative / automation)

Browser login isn't always practical (headless servers, CI, scripts). In those cases use a Personal Access Token (PAT).

Create a token

  1. In a browser, go to https://github.austin.utexas.edu/settings/tokens.

  2. Generate a new token with at least the repo, read:org, and gist scopes (add workflow if you'll manage GitHub Actions).

  3. Copy the token — you won't be able to view it again.

Log in with the token via stdin

macOS / Linux / Git Bash:

echo "YOUR_TOKEN" | gh auth login --hostname github.austin.utexas.edu --with-token

Windows PowerShell:

"YOUR_TOKEN" | gh auth login --hostname github.austin.utexas.edu --with-token

Piping the token via --with-token keeps it out of your shell history and off the command line, which is safer than passing it as an argument.

Environment-variable method (no stored credentials)

For CI runners or ephemeral shells, gh reads the token from the environment instead of the config store. For an enterprise host use GH_ENTERPRISE_TOKEN (and GH_HOST to set the default host):

macOS / Linux / Git Bash:

export GH_HOST=github.austin.utexas.edu export GH_ENTERPRISE_TOKEN=YOUR_TOKEN

Windows PowerShell:

$env:GH_HOST = "github.austin.utexas.edu" $env:GH_ENTERPRISE_TOKEN = "YOUR_TOKEN"

GH_ENTERPRISE_TOKEN is the enterprise-specific variable. GH_TOKEN / GITHUB_TOKEN apply to github.com. When both a stored login and an env-var token exist, the environment variable wins.


4. Make it your default host (optional)

If you work almost exclusively against GHES, set it as the default so you can drop the --hostname flag:

export GH_HOST=github.austin.utexas.edu

Add that line to your shell profile (~/.zshrc, ~/.bashrc, or a PowerShell $PROFILE) to make it persistent.


5. Test it end-to-end

# List repos you can access on the enterprise host gh repo list --hostname github.austin.utexas.edu # Clone a repo (gh handles auth over HTTPS) gh repo clone your-org/your-repo

If clones and API calls succeed, you're fully set up.


Troubleshooting

Symptom

Likely cause / fix

Symptom

Likely cause / fix

Commands hit github.com instead of GHES

Missing --hostname github.austin.utexas.edu, or set GH_HOST.

could not connect / TLS or timeout errors

Not connected to the UT VPN (or on-campus network).

gh: command not found after install

Open a new terminal so PATH refreshes.

Auth succeeds but git push/clone prompts for a password

Re-run gh auth login and choose HTTPS + Yes to configure Git credentials, or run gh auth setup-git --hostname github.austin.utexas.edu.

Token rejected

Token expired or missing scopes; regenerate with repo, read:org, gist.


Reference