Skip to content

gh codespace ssh --config references non-existing ssh key #9817

Closed

Description

@liskin

Describe the bug

gh codespace ssh --config generates a config that assumes the existence of ~/.ssh/codespaces.auto, and thus any subsequent ssh cs.my-space.my-branch invocations fail.

$ gh --version
gh version 2.46.0 (2024-03-26 Debian 2.46.0-1)
https://github.com/cli/cli/releases/tag/v2.46.0

Steps to reproduce the behavior

$ gh codespace ssh --config >>~/.ssh/config
$ ssh -v cs.my-space.my-branch
[…]
error getting ssh server details: failed to read public key file: open /home/tomi/.ssh/codespaces.auto.pub: no such file or directory
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

Expected vs actual behavior

I expected to be able to connect without getting an error.

This was discussed earlier in #5958 (comment) - but never resolved. It's quite baffling actually - why reference a key file that will never be generated? How can that ever work?

Activity

  1. added
    bug
    on Oct 25, 2024
  2. added
    needs-triage
    on Oct 25, 2024
  3. liskin commented on Oct 25, 2024

    @liskin
    Author

    Workaround: gh codespace ssh --config | sed -e 's| -i.*codespaces.auto||; /IdentityFile/d;' 🤣 🤦

  4. added
    gh-codespace
    on Oct 31, 2024
  5. andyfeller commented on Oct 31, 2024

    @andyfeller
    Contributor

    cc: @cli/codespaces

  6. cmbrose commented on Nov 4, 2024

    @cmbrose
    Member

    Thanks for calling this out @liskin - and thanks for the patience while I paged this back into memory!

    I think the fix for this would be to update the handling of the -i check here. Currently if -i is specified (as it is with --config) then selectSSHKeys will just immediately exit.

    Instead, we should check if -i is the automatic key, and if so, create it if it doesn't exist.

  7. cmbrose commented on Nov 5, 2024

    @cmbrose
    Member

    Proposed fix at #9881

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggh-codespaceneeds-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions