Skip to content

Add global --ssh-args argument for SSH/Docker/Vagrant execution#6206

Open
Copilot wants to merge 6 commits intomainfrom
copilot/add-global-ssh-args
Open

Add global --ssh-args argument for SSH/Docker/Vagrant execution#6206
Copilot wants to merge 6 commits intomainfrom
copilot/add-global-ssh-args

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

WP-CLI's --ssh flag only accepts connection strings, preventing users from passing tool-specific arguments like SSH options (-o ConnectTimeout=5), Docker flags (--env), or Vagrant parameters.

Changes

Core Implementation

  • Added ssh-args to global config spec with multiple: true support
  • Modified generate_ssh_command() to inject escaped args into all scheme commands (SSH, Docker, Docker Compose, Docker Compose Run, Vagrant)
  • Filter --ssh-args from arguments passed to remote WP-CLI to prevent double-processing

Supporting Changes

  • Added ssh-args to alias specification for alias support
  • Updated PHPStan GlobalConfig type definition

Usage

# SSH timeout
wp --ssh=server --ssh-args="-o ConnectTimeout=5" core version

# Multiple args
wp --ssh=server --ssh-args="-o ConnectTimeout=5" --ssh-args="-o ServerAliveInterval=10" core version

# Docker environment
wp --ssh=docker:wordpress --ssh-args="--env MY_VAR=value" core version

# In aliases
@prod:
  ssh: user@prod.example.com
  ssh-args:
    - "-o ConnectTimeout=10"
    - "-o ProxyJump=bastion"

All arguments are shell-escaped via escapeshellarg() before execution.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php '-d short_open_tag=Off' '-d error_reporting=E_ALL' '-n' '-l' './bundle/rmccue/requests/src/Excepgit features/config.feature /usr/bin/grep quests/src/Auth./home/REDACTED/work/wp-cli/wp-cli/vendor/wp-cli/wp-cli-tests/bin/run-phpstan-tests--no-color r.php cal/bin/grep grep -l ssh features/http-logging.feature p/bin/grep php/class-wp-cliphp hp .php grep (dns block)
  • nosuchhost_asdf_asdf_asdf.com
    • Triggering command: /usr/bin/php php vendor/bin/phpunit --color=always --bootstrap ./vendor/wp-cli/wp-cli-tests/tests/bootstrap.php '-d short_open_tag=Off' '-d error_reporting=E_ALL' '-n' '-l' './bundle/rmccue/requests/src/Excepgit features/config.feature /usr/bin/grep quests/src/Auth./home/REDACTED/work/wp-cli/wp-cli/vendor/wp-cli/wp-cli-tests/bin/run-phpstan-tests--no-color r.php cal/bin/grep grep -l ssh features/http-logging.feature p/bin/grep php/class-wp-cliphp hp .php grep (dns block)
  • wordpress
    • Triggering command: /usr/bin/ssh ssh -o ConnectTimeout=5 -T -vvv wordpress wp '--debug' '--ssh-args=-o ConnectTimeout=5' '--version' k/wp-cli/wp-cli/features/validation.feature mposer/vendor/bin/grep tests/SchemaValiwhich 416.php rgo/bin/grep grep -l ssh k/wp-cli/wp-cli/features/cli-info.feature grep ssh 414.php mposer/vendor/bin/grep grep (dns block)
    • Triggering command: /usr/bin/ssh ssh -o ConnectTimeout=5 -o ServerAliveInterval=10 -T -vvv wordpress wp '--debug' '--ssh-args=-o ConnectTimeout=5' '--ssh-args=-o ServerAliveInterval=10' '--version' /home/REDACTED/.composer/vendor/bin/grep tests/UtilsTest.sh 402.php ep grep hpcs�� ssh k/wp-cli/wp-cli/features/formatter.feature tnet/tools/git ssh 429.php /home/REDACTED/.co-a grep (dns block)
    • Triggering command: /usr/bin/ssh ssh -o ConnectTimeout=5 -T -vvv wordpress wp '--debug' '--version' -d short_open_tag=Off (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Add global --ssh-args argument</issue_title>
<issue_description>Some SSH functionality can currently not be used (or only through workarounds) because we cannot directly pass arguments to SSH, we only have the connection string to communicate with it.

One of these limitations can be seen here: #5100

Adding a new global argument to pass arguments to SSH would make this more flexible and open up access to the full functionality of SSH.

As we are using the --ssh flag for access to docker & vagrant as well, this would also allow the user to pass arguments to these as well.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 25, 2026 16:55
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add global --ssh-args argument for SSH functionality Add global --ssh-args argument for SSH/Docker/Vagrant execution Jan 25, 2026
Copilot AI requested a review from swissspidy January 25, 2026 17:05
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 76.19048% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/WP_CLI/Runner.php 64.28% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review February 3, 2026 14:19
@swissspidy swissspidy requested a review from a team as a code owner February 3, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:cli Related to 'cli' command command:cli-utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add global --ssh-args argument

2 participants