How to Install GitHub CLI on Rocky Linux 10, 9 and 8

Last updated Friday, May 15, 2026 6:17 pm Joshua James 7 min read

Pull requests, issues, releases, and GitHub Actions runs are easier to manage when they are available from the same shell you already use for Git. To install GitHub CLI on Rocky Linux, add GitHub’s official RPM repository, install the gh package with DNF, and authenticate the client before running repository commands.

The RPM workflow works on Rocky Linux 10, 9, and 8 with DNF4. Git is a required dependency, so the install section adds Git before restricting DNF to the GitHub CLI repository for the gh package.

Install GitHub CLI on Rocky Linux

Update Rocky Linux Before Installing GitHub CLI

Refresh package metadata and apply pending system updates before adding the GitHub repository. When no updates are pending, DNF ends with:

sudo dnf upgrade --refresh
Dependencies resolved.
Nothing to do.
Complete!

These commands use sudo because repository and package changes write to system-managed directories. If your account cannot use sudo, switch to an administrator account or configure sudo access before continuing.

Add the Official GitHub CLI RPM Repository

Rocky Linux’s default repositories do not provide the gh package, so plain dnf install gh needs GitHub’s repository first. GitHub maintains the RPM repository used here, and its official Linux install notes list separate instructions for DNF4 and DNF5. Rocky Linux 10, 9, and 8 use the DNF4 form.

Install the DNF plugin that provides config-manager:

sudo dnf install 'dnf-command(config-manager)'

Add the GitHub CLI repository file:

sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
Adding repo from: https://cli.github.com/packages/rpm/gh-cli.repo

Confirm that DNF can see the repository and that the gh package resolves from it:

dnf repolist --all | grep gh-cli
dnf repoquery --repo gh-cli --available gh --qf '%{name} %{repoid}' | sort -u
gh-cli                     packages for the GitHub CLI                  enabled
gh gh-cli

Current repository metadata publishes gh for x86_64, aarch64, armv6hl, and i386. DNF selects the package that matches your system architecture automatically, so the commands do not need an architecture option.

Install Git and GitHub CLI with DNF

Install Git first. This prevents dependency failures on minimal systems when the next command limits the gh package selection to the GitHub repository.

sudo dnf install git

Install GitHub CLI from the official repository:

sudo dnf install gh --repo gh-cli

During the first install, DNF imports the GitHub CLI signing keys from the same package host. Relevant output includes:

Importing GPG key 0x75716059:
 Userid     : "GitHub CLI <opensource+cli@github.com>"
 Fingerprint: 2C61 0620 1985 B60E 6C7A C873 23F3 D4EA 7571 6059
 From       : https://cli.github.com/packages/githubcli-archive-keyring.asc
Key imported successfully
Importing GPG key 0x62313325:
 Userid     : "GitHub CLI <opensource+cli@github.com>"
 Fingerprint: 7F38 BBB5 9D06 4DBC B3D8 4D72 5612 B364 6231 3325
 From       : https://cli.github.com/packages/githubcli-archive-keyring.asc
Key imported successfully

Verify GitHub CLI on Rocky Linux

Check that the gh command is on your path and prints its version:

command -v gh
gh --version
/usr/bin/gh
gh version 2.92.0 (2026-04-28)
https://github.com/cli/cli/releases/tag/v2.92.0

Your version may be newer because the GitHub repository updates independently from Rocky Linux point releases.

Authenticate and Configure GitHub CLI on Rocky Linux

Log In to GitHub CLI

Start the interactive login flow for github.com:

gh auth login

The prompts ask for the GitHub host, Git transport, and authentication method:

? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser

Choose HTTPS for the simplest credential-helper workflow, or choose SSH if you already use SSH keys for GitHub. The GitHub CLI auth manual notes that browser login stores a token in the system credential store when one is available; on lean server installs without a credential store, gh auth status shows where the token was saved.

For a headless session with a classic personal access token, pass the token on standard input instead of typing it into a command line. The first command uses chmod file permissions so only your user can read the temporary token file:

chmod 600 mytoken.txt
gh auth login --with-token < mytoken.txt

After login succeeds, remove the temporary token file:

rm -f mytoken.txt

For fine-grained personal access tokens and automation, prefer a protected environment variable supplied by your CI system, shell secret manager, or orchestration platform instead of keeping a token file in your home directory. GitHub CLI reads GH_TOKEN or GITHUB_TOKEN for github.com, and GH_ENTERPRISE_TOKEN or GITHUB_ENTERPRISE_TOKEN with GH_HOST for GitHub Enterprise Server.

Verify GitHub CLI Authentication

Check the current login state:

gh auth status

Before authentication, GitHub CLI reports:

You are not logged into any GitHub hosts. To log in, run: gh auth login

After a successful login, the same command lists the host, active account, Git protocol, token storage location, and granted scopes. Re-run it whenever a tool reports that gh is installed but not authenticated.

Set a Custom GH_CONFIG_DIR

GitHub CLI normally stores configuration under $XDG_CONFIG_HOME/gh or $HOME/.config/gh on Linux. The GitHub CLI environment reference documents GH_CONFIG_DIR for separate profiles, automation, or temporary authentication state.

Use a custom config directory for one command by prefixing the command with GH_CONFIG_DIR:

mkdir -p "$HOME/.config/gh-work"
GH_CONFIG_DIR="$HOME/.config/gh-work" gh config set prompt disabled
GH_CONFIG_DIR="$HOME/.config/gh-work" gh config get prompt
disabled

Run login the same way when you want that directory to own the credentials:

GH_CONFIG_DIR="$HOME/.config/gh-work" gh auth login

If you later unset GH_CONFIG_DIR, GitHub CLI returns to its normal config path and may appear unauthenticated because it is reading a different profile.

Use GitHub Enterprise Server

For GitHub Enterprise Server, authenticate against the enterprise hostname instead of github.com:

gh auth login --hostname github.example.com

Replace github.example.com with your organization’s host. The rest of the authentication flow is the same, but credentials and active accounts are stored per host.

Refresh Scopes or Switch Accounts

Some GitHub operations need extra token scopes. For example, pushes that modify workflow files may need the workflow scope, and project operations may need the project scope.

gh auth refresh --scopes workflow

When multiple accounts are authenticated, switch the active account for the current host:

gh auth switch

After authentication, configure Git to use GitHub CLI as a credential helper:

gh auth setup-git

Git itself does not have a separate GitHub login. Account authentication lives in GitHub CLI, SSH keys, credential helpers, or HTTPS tokens, depending on how your repository remote is configured.

Use GitHub CLI on Rocky Linux

GitHub CLI is separate from GitHub Desktop. It gives shell access to GitHub workflows, while Git still handles local commits, branches, merges, and remotes. If Git itself is new to you, use the Rocky Linux Git install guide to configure your author identity and basic Git workflow.

Clone a Repository

Clone a repository by owner and repository name:

gh repo clone cli/cli

If your Git protocol is set to HTTPS or SSH during login, gh repo clone follows that preference unless you provide a full clone URL.

Push Local Commits

GitHub CLI does not replace Git for local commits or normal pushes. Use Git to push your branch, then use gh for the GitHub-side workflow such as pull requests, issues, and releases:

git push -u origin feature-branch

Create a Pull Request

From inside a Git repository with a branch ready for review, create a pull request interactively:

gh pr create

Add --web when you want GitHub to open the pull request form in a browser, or use --title, --body, and --base for non-interactive creation.

List Issues

List open issues in the current repository:

gh issue list

Filter the list by assignee, label, state, or search query:

gh issue list --assignee @me
gh issue list --label bug
gh issue list --state all

Run a GitHub Actions Workflow

Trigger a workflow that supports the workflow_dispatch event:

gh workflow run triage.yml

If you are outside the repository directory, add --repo OWNER/REPO. The workflow file must allow manual dispatch or GitHub rejects the request.

Create a GitHub Repository from Local Code

From an existing project directory, create the remote repository and push the current local repository:

gh repo create my-project --private --source=. --remote=origin --push

Use --public instead of --private when the repository should be visible publicly. The GitHub CLI manual covers every subcommand, flag, and output format once the base install is working.

GitHub Copilot CLI Note

gh copilot is a separate GitHub Copilot CLI entry point and is currently preview functionality. Running it may download an extra payload under ~/.local/share/gh/copilot, and gh copilot --remove removes that Copilot payload. Installing gh only sets up the base GitHub CLI package.

Update GitHub CLI on Rocky Linux

GitHub CLI updates through DNF because the repository file remains in /etc/yum.repos.d/. Update only the gh package with:

sudo dnf update gh --repo gh-cli

When the package is already current, DNF reports:

Dependencies resolved.
Nothing to do.
Complete!

A normal system update also includes GitHub CLI:

sudo dnf upgrade --refresh

Troubleshoot GitHub CLI on Rocky Linux

DNF Reports Nothing Provides Git

If you run the GitHub CLI package install before Git is installed on a minimal system, DNF can stop with a dependency error:

Error:
 Problem: cannot install the best candidate for the job
  - nothing provides git needed by gh-2.92.0-1.x86_64 from gh-cli

Install Git from Rocky Linux AppStream first, then repeat the GitHub CLI install:

sudo dnf install git
sudo dnf install gh --repo gh-cli

Verify both commands resolve:

command -v git
command -v gh
/usr/bin/git
/usr/bin/gh

CI Checks Unavailable or gh Not Authenticated

Some developer tools show messages such as CI checks unavailable. Check that gh is installed and authenticated. when the gh binary is missing, the account is not logged in, or the token lacks the needed scope.

command -v gh || echo "gh is not installed"
gh auth status

If the status command says you are not logged in, authenticate again and refresh any missing workflow scope:

gh auth login
gh auth refresh --scopes workflow
gh auth setup-git

Use gh auth switch when the wrong account is active for the host you are working with.

OAuth Application Needs Reauthorization

If a command reports To access this repository, you must re-authorize the OAuth Application 'GitHub CLI'., refresh the stored credentials for github.com, then check the login state again:

gh auth refresh --hostname github.com --scopes repo,workflow
gh auth status

The refresh command opens the GitHub authorization flow. Add or remove scopes to match the operation that failed, then retry the original gh command.

GH_CONFIG_DIR Uses the Wrong Profile

A custom GH_CONFIG_DIR can make a working login look missing because GitHub CLI is reading another config directory. Check whether the variable is set, then unset it if you want to return to the default profile:

printf '%s\n' "${GH_CONFIG_DIR:-default gh config path}"
unset GH_CONFIG_DIR
gh auth status

If you intentionally use multiple profiles, keep GH_CONFIG_DIR in the shell startup file, service unit, or CI environment that runs gh so each command reads the same credentials.

GitHub CLI Repository Is Missing or Disabled

If updates fail because DNF cannot find gh-cli, inspect the repository list:

dnf repolist --all | grep gh-cli

Enable an existing disabled repository:

sudo dnf config-manager --set-enabled gh-cli

If the repository file is missing, add it again:

sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo

Remove GitHub CLI from Rocky Linux

Remove the GitHub CLI Package

Remove the installed gh package with DNF:

sudo dnf remove gh

Leave Git installed if you still use it for local repositories. Remove Git separately only when no other workflow on the system depends on it.

Remove the GitHub CLI Repository

Delete the repository file when you no longer want DNF to check the GitHub CLI package source:

sudo rm -f /etc/yum.repos.d/gh-cli.repo
sudo dnf clean expire-cache

Verify that the repository is no longer enabled and the repository file is gone:

dnf repolist --enabled | grep gh-cli || echo "GitHub CLI repository is not enabled"
test ! -e /etc/yum.repos.d/gh-cli.repo && echo "GitHub CLI repository file removed"
GitHub CLI repository is not enabled
GitHub CLI repository file removed

Remove GitHub CLI Signing Keys

DNF can leave imported GitHub CLI RPM signing keys after the package and repository are removed. Keeping them is harmless if you plan to reinstall later. For full trust cleanup, remove only the matching GitHub CLI key packages:

mapfile -t gh_keys < <(rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' | grep -Ei 'gpg-pubkey-(75716059|62313325)-' || true)

if ((${#gh_keys[@]})); then
  sudo rpm -e "${gh_keys[@]}"
else
  echo "No GitHub CLI signing keys found"
fi

Remove GitHub CLI User Configuration

Package removal does not delete saved hosts, tokens, or profile settings. Remove the default config directory only when you are sure those credentials are no longer needed.

Removing ~/.config/gh permanently deletes saved GitHub CLI configuration. Back up that directory first if you need saved hosts, tokens, aliases, or extension settings.

rm -rf ~/.config/gh

If you used a custom GH_CONFIG_DIR, remove that directory instead of, or in addition to, the default path.

Verify GitHub CLI Removal

Confirm that the gh command is no longer available:

command -v gh || echo "gh command not found"
gh command not found

Conclusion

GitHub CLI is ready on Rocky Linux through GitHub’s RPM repository, with DNF handling normal package updates and Git providing the version-control backend that gh expects. After authentication, the same terminal can clone repositories, open pull requests, inspect issues, and trigger Actions workflows without switching back to the browser for every GitHub task.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: