Unable to use glab with alternative ssh port

Checklist

  • I'm using the latest version of the extension (Run glab --version)
    • Extension version: glab version 1.28.1 (2023-04-21)
  • Operating system and version: macOS 13.3.1 (22E261)
  • Gitlab.com or self-managed instance? gitlab.com
  • GitLab version (if self-managed) N/A (Use the version endpoint, like this: gitlab.my-company.com/api/v4/version)
  • I have performed glab auth status to check for authentication issues

Summary

When git is configured to use the alternative SSH port/host for GitLab, any glab commands requiring auth are completely non-functional.

Steps to reproduce

Add this to your ~/.ssh/config:

Host gitlab.com
    Hostname altssh.gitlab.com
    User git
    Port 443
    PreferredAuthentications publickey

Verify that code in a git repo using a gitlab.com host can be pushed/pulled as expected. Now, try to use a glab command requiring auth such as glab mr create.

What is the current bug behavior?

glab exits with code 1 and error message:

Could not create recovery file: none of the git remotes configured for this repository points to a known GitLab host. Please use `glab auth login` to authenticate and configure a new host for glabnone of the git remotes configured for this repository points to a known GitLab host. Please use `glab auth login` to authenticate and configure a new host for glab

Contrary to what the error message indicates, logging in with a brand new token does not resolve the issue.

What is the expected correct behavior?

glab should function normally as if the regular SSH host were being used.

Relevant logs and/or screenshots

$ glab auth status
gitlab.com
  ✓ Logged in to gitlab.com as elashakili (/Users/eliotlash/.config/glab-cli/config.yml)
  ✓ Git operations for gitlab.com configured to use ssh protocol.
  ✓ API calls for gitlab.com are made over https protocol
  ✓ REST API Endpoint: https://gitlab.com/api/v4/
  ✓ GraphQL Endpoint: https://gitlab.com/api/graphql/
  ✓ Token: **************************

Possible fixes

Assignee Loading
Time tracking Loading