Skip to main content

Using GitHub CLI on your Device

This guide walks through installing the GitHub CLI (gh) on a device via the obacht web terminal, authenticating with a GitHub Personal Access Token, and cloning a private repository.


1. Open the Terminal

Navigate to the device in obacht and confirm it is Online.

Device overview — online

Go to the Terminal tab and click Connect.

Terminal tab — Connect button

If your SSH key has a passphrase, enter it when prompted.

SSH key passphrase dialog

The terminal connects to the device via the obacht SSH gateway.

Connecting to SSH gateway

Once connected you have a full shell as the obacht user.

Terminal connected — shell prompt


2. Install the GitHub CLI

Run the following command to update the package index and install gh:

sudo apt update && sudo apt install gh -y

Running the install command

apt fetches and installs the gh package. Installation takes about 30 seconds.

gh installation completing


3. Authenticate with GitHub

Run gh auth login to start the interactive authentication flow.

gh auth login

What account do you want to log into? — select GitHub.com.

gh auth login — select GitHub.com

What is your preferred protocol for Git operations on this host? — select HTTPS.

gh auth login — select HTTPS

Authenticate Git with your GitHub credentials? — confirm with Y.

gh auth login — confirm Git credentials

How would you like to authenticate GitHub CLI? — select Paste an authentication token.

The "Login with a web browser" option requires a browser on the device and does not work headlessly. Use a token instead.

gh auth login — paste token selected


4. Create a Personal Access Token

In a separate browser tab, go to github.com/settings/tokens and click Generate new token → Generate new token (classic).

GitHub — Personal Access Tokens page

Give the token a name, set an expiration, and check the repo scope. This grants full access to private repositories.

GitHub — New token form with repo scope

Scroll to the bottom and click Generate token. Copy the token immediately — GitHub will not show it again.

GitHub — Generate token button


5. Paste the Token

Back in the terminal, paste the token at the Paste your authentication token: prompt and press Enter.

Terminal — pasting the token

gh validates the token and stores the credentials. You are now authenticated.


6. Clone a Private Repository

Use gh repo clone followed by the repository name (or owner/repo for repositories outside your account) to clone it.

gh repo clone <repository-name>

Terminal — gh repo clone command

The repository is cloned into the current directory.

Terminal — clone completed

The clone is complete. You can now work with the repository directly on the device.