platformsh / legacy-cli

This is the legacy version of Platform.sh's command-line interface. The new version is at: https://github.com/platformsh/cli
https://docs.platform.sh/administration/cli.html
MIT License
224 stars 121 forks source link

Skip automatic SSH auth when the host is external #1413

Closed pjcdawkins closed 4 months ago

pjcdawkins commented 4 months ago

This PR reverts the fix in 3b07ab8f0126becd5e14c2b6e2373c4ab5922fed in favour of a neater approach to the same problem. This omits the automatic SSH auth arguments (CertificateFile, IdentityFile etc) for the SSH command line when the SSH hostname is "external". Any user-provided SSH options (e.g. via -o or -i) will still be added to the command line.

The hostname is detected as external if it does not match any of the ssh.domain_wildcards configuration setting (e.g. *.platform.sh). If the configuration is not provided, or the hostname cannot be detected (unlikely but possible), then it is treated as internal, as this is the more common situation. An external hostname is only really expected for Git connections on projects that have an external code repository integrated (e.g. it has a Bitbucket, GitHub or GitLab integration).

This affects any SSH-related subcommand, including ssh, git, rsync, and scp. Many CLI commands are therefore affected (anything that opens an SSH connection, directly or indirectly), including branch, checkout, drush, get, mongo, mount:download, mount:upload, push, redis, scp, sql, ssh, tunnel:open, tunnel:single, and xdebug.

Please test for Platform.sh or Upsun with:

# Download the build for this PR
curl -s https://pr-1413-x7ynvii-mpaw4nkgdwaea.eu-2.platformsh.site/platform.phar > /tmp/platform-pr-1413.phar

# Download the normal Upsun CLI config
curl -s https://raw.githubusercontent.com/platformsh/cli/main/internal/config/upsun-cli.yaml > /tmp/upsun-cli.yaml

# Create aliases
alias platform='php /tmp/platform-pr-1413.phar'
alias upsun='CLI_CONFIG_FILE=/tmp/upsun-cli.yaml php /tmp/platform-pr-1413.phar'