Skip to content

support .ssh/config Include directives #2179

@sclem

Description

@sclem

Describe the feature or problem you’d like to solve

This is sort of related to #326 - I use different ssh keys for organizations on github, so I have Host aliases set up in ~/.ssh/config.d/org_name files. One of these aliases may look like this:

Host github.com-org_name
    HostName github.com
    User sclem
    IdentityFile ~/.ssh/org_name_key
    IdentitiesOnly yes

git remote will look like: git@github.com-org_name:Org/Repo.git

My top level .ssh/config contains some global wildcards and Include ~/.ssh/config.d/*, which is documented in the ssh_config man page.

I perused through the codebase to find that gh cli does in fact read and parse ~/.ssh/config for these Host aliases to resolve the upstream host. This works correctly, however I couldn't find any documentation on this behavior and it doesn't support multiple files.

The error seen (after auth, if alias is not in .ssh/config directly):

none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login`

Proposed solution

Read all the ssh_config files the user has configured. Workaround for now is to put all hosts into my .ssh/config. This may get tricky, considering man ssh_config supports conditional includes inside a Match/Host block.

Another idea is to support host: github.com in hosts.yml and don't parse ssh config to try and resolve the remote hostname, instead have hosts.yml "keys" match the remote "domain" directly.

Additional context

Workaround for now is to put everything into .ssh/config directly

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions