Repository navigation
Description
Describe the bug
When running gh auth login on a remote/headless-ish Linux host over SSH, choosing "Login with a web browser" can become confusing or appear stuck after the prompt:
! First copy your one-time code: XXXX-XXXX
- Press Enter to open github.com in your browser...
In this environment, pressing Enter attempted to open a browser on the remote Linux host rather than making it clear that the user can complete the device flow in a browser on their local machine. The remote host had terminal/browser alternatives installed, so the user saw browser-like content in the SSH terminal and attempted to continue there.
Meanwhile, entering the one-time code in the local Mac browser did not appear to make progress from the user's perspective. The login succeeded only after retrying with a no-op browser command:
GH_BROWSER=/bin/true gh auth loginWith that workaround, gh did not open a remote terminal/browser UI and the normal device-code flow completed using the local Mac browser.
This seems closely related to the headless-machine UX discussed in #5500, but this case is a bit different: a browser command exists and may succeed by opening a terminal/browser UI on the remote host, even though that is not the browser the user expects when connected over SSH.
Affected version
gh version 2.92.0 (2026-04-28)
https://github.com/cli/cli/releases/tag/v2.92.0
Environment:
Linux wing 6.12.75+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.75-1+rpt1 (2026-03-11) aarch64 GNU/Linux
Debian GNU/Linux 13 (trixie)
Architecture: arm64
Browser-related commands/config detected on the host:
/usr/bin/xdg-open
/usr/bin/lynx
/usr/bin/www-browser
www-browser -> /usr/bin/lynx
x-www-browser alternative also configured
The user was connected from macOS to the Linux host via SSH and intended to complete device authentication in the macOS browser.
Steps to reproduce the behavior
- SSH from a desktop/laptop into a Linux host that has
ghinstalled and has a terminal browser / browser alternative such aslynx,www-browser, or similar. - Run
gh auth login. - Select GitHub.com, HTTPS, and "Login with a web browser".
- At
Press Enter to open github.com in your browser..., press Enter. - Observe that
ghattempts to open a browser on the remote host / inside the SSH terminal, which is not the local desktop browser the user expects. - Try entering the device code in the local desktop browser. From the user's perspective, the SSH terminal still appears stuck or focused on the remote browser flow.
- Retry with
GH_BROWSER=/bin/true gh auth login; the flow completes successfully using the local browser.
Expected vs actual behavior
Expected:
- For SSH/headless contexts,
gh auth loginshould make it obvious that the user can manually openhttps://github.com/login/deviceon another machine/browser and enter the displayed code. - If a terminal browser is opened on the remote host,
ghshould not make the flow appear stuck or imply that this remote browser is the required path. - Ideally, there should be a clear documented/non-interactive way to say "do not open a browser; just print the URL/code and keep polling".
Actual:
- Pressing Enter tried to open a browser on the remote host.
- Because a terminal/browser alternative existed, the fallback did not simply fail and print manual instructions; it led the user into a confusing remote terminal-browser experience.
- The successful workaround was to set
GH_BROWSER=/bin/trueso the browser-open step becomes a no-op while the device-code polling continues.
Logs
The successful workaround was:
GH_BROWSER=/bin/true gh auth loginAfter authentication:
github.com
✓ Logged in to github.com account whiwoon (.../.config/gh/hosts.yml)
- Active account: true
- Git operations protocol: https
Related prior discussion: #5500
Activity
babakks commentedon May 18, 2026
Thanks for reporting this, @whiwoon! 🙏
Anyway, this is a UX gap. The device flow technically works, but when a terminal browser like
lynxis registered on the remote host, the experience becomes confusing becauseghhappily opens it inside the SSH session rather than signaling that you should use a browser on your local machine.Forcing the invocation to be non-interactive (e.g.
gh auth login | cat) can be helpful sinceghwon't try to open the browser and will just print the URL. But the problem is there'll be no interactive prompting which is not nice.Related: #5500 (headless machine with no browser at all, which is a different scenario from yours where a browser exists but isn't the right one).
I'm thinking of addressing this with two changes:
A new
--no-browserflag ongh auth loginthat suppresses theBrowse()call entirely. You'd still get the full interactive experience (protocol selection, SSH key prompt, etc.) butghwould just print the URL for you to open manually on whatever machine you prefer. This is similar to how the non-interactive path already works today (which is whygh auth login | cathappens to work as a workaround, but you'll miss the interactive prompts).Best-effort SSH session detection (checking env vars like
SSH_TTY). If detected,ghwould print a hint on stderr suggesting--no-browser, without changing any default behavior. This keeps things non-breaking for users who genuinely want to open a browser on the remote host.@whiwoon, what do you think of this approach? Would
--no-browserplus the SSH hint have resolved the confusion in your case?github-actions commentedon May 18, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
whiwoon commentedon May 18, 2026
Yes, I think
--no-browserplus an SSH-session hint would have resolved the confusion in my case.The confusing part was that
gh auth loginopenedlynxinside the SSH session, which made it feel like that was the expected path. I still wanted the normal interactive prompts; I just neededghto print the URL so I could open it in a browser on my local machine.A best-effort hint when
SSH_TTYis present sounds like the right non-breaking behavior to me, since some users may intentionally use a browser on the remote host.Thanks for taking a look at this!
rbutleriii commentedon Jul 29, 2026
nikelborm commentedon Aug 21, 2026
Another solution I found is that, instead of remembering to set this environment variable, you can permanently set it in the config with this command:
gh config set browser /bin/true