Skip to content

Comments

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

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

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

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

✅ Implementation Complete: --ssh-args Global Argument

Successfully implemented the global --ssh-args argument for WP-CLI, addressing issue #5100.

Implementation Checklist

  • Add ssh-args to global config specification in php/config-spec.php
  • Add ssh-args to alias specification in php/WP_CLI/Configurator.php
  • Add ssh-args to GlobalConfig type in php/class-wp-cli.php for PHPStan
  • Modify generate_ssh_command() in php/WP_CLI/Runner.php to append ssh-args to:
    • SSH command
    • Docker command
    • Docker Compose command
    • Docker Compose Run command
    • Vagrant command
  • Filter --ssh and --ssh-args from arguments passed to remote WP-CLI (improved regex)
  • Add Behat test for SSH scheme with --ssh-args
  • Add Behat test for multiple SSH args
  • Add Behat test for Docker scheme with --ssh-args
  • Run linting (passed ✅)
  • Run code style check (passed ✅)
  • Run static analysis (passed ✅)
  • Manual testing (passed ✅)
  • Address code review feedback
  • Security validation (proper escaping ✅)

Recent Changes

Improved SSH flag filtering regex (latest commit):

  • Added start anchor (^) to prevent false positives
  • Changed to match both = separator and end-of-string for space-separated flags
  • Now correctly filters: --ssh, --ssh=value, --ssh-args, --ssh-args=value

Changes Summary

5 files modified (+47 lines, -7 lines)

Usage Examples

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

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

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

Key Features

✨ Multiple arguments supported via repeated --ssh-args flags
✨ Works with all schemes: SSH, Docker, Docker Compose, Vagrant
✨ Proper shell escaping for security
✨ Arguments filtered from remote command (both = and space-separated)
✨ Can be used in aliases
✨ Fully backward compatible

Ready for review and merge!

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
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

…nt false positives

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

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