opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(cli): support SSH aliases when installing opencode GitHub app

Open ManuSanchez02 opened this issue 16 hours ago • 1 comments

What does this PR do?

Fixes https://github.com/anomalyco/opencode/issues/9317.

The fix consists of running ssh -G alias to resolve the alias and find the hostname configured in the .ssh/config file. If said hostname is github.com, then proceed with the installation. Otherwise, raise the existing error.

Fix description

  1. Run git remote get-url origin . a. If the output contains github.com as a hostname, install the app. b. If not, continue with the alias resolution.
  2. Run ssh -G alias to resolve the alias.
  3. Extract the hostname from the output of ssh -G alias.
  4. Verify the hostname is github.com. a. If it matches, proceed with the installation. b. If it doesn't match, raise the existing error.

The existing behaviour remains if no alias is used.

Fix screenshot

Screenshot from 2026-01-18 21-12-04

How did you verify your code works?

Manual verification by running bun dev github install on a repo. Also, added unit tests to ensure the behavior is as expected.

How to verify the fix?

Set up a ssh alias as described in https://github.com/anomalyco/opencode/issues/9317. Then, clone a repo using the alias. Finally, run opencode github install in said repo.

ManuSanchez02 avatar Jan 19 '26 01:01 ManuSanchez02