Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions features/aliases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,20 @@ Feature: Create shortcuts to specific WordPress installs
Running SSH command: ssh -i 'identityfile.key' -T -vvv
"""

Scenario: Vagrant SSH disables strict host key checking
Given a WP installation in 'foo'
And a wp-cli.yml file:
"""
@foo:
ssh: vagrant
"""

When I try `wp @foo --debug --version`
Then STDERR should contain:
"""
Running SSH command: ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -T -vvv '' 'wp --debug --version'
"""

Scenario: SSH alias expands tilde in path
Given a WP installation in 'foo'
And a wp-cli.yml file:
Expand Down
4 changes: 4 additions & 0 deletions php/WP_CLI/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ private function generate_ssh_command( $bits, $wp_command ) {
}

// Vagrant ssh-config.
$is_vagrant_ssh = false;
if ( 'vagrant' === $bits['scheme'] ) {
$cache = WP_CLI::get_cache();
$cache_key = 'vagrant:' . $this->project_config_path;
Expand All @@ -879,6 +880,7 @@ private function generate_ssh_command( $bits, $wp_command ) {
$bits['port'] = isset( $values['Port'] ) ? $values['Port'] : '';
$bits['user'] = isset( $values['User'] ) ? $values['User'] : '';
$bits['key'] = isset( $values['IdentityFile'] ) ? $values['IdentityFile'] : '';
$is_vagrant_ssh = true;
}

// If we could not resolve the bits still, fallback to just `vagrant ssh`
Expand Down Expand Up @@ -916,6 +918,8 @@ private function generate_ssh_command( $bits, $wp_command ) {
$bits['port'] ? sprintf( '-p %d', (int) $bits['port'] ) : '',
// @phpstan-ignore cast.string
$bits['key'] ? sprintf( '-i %s', escapeshellarg( (string) $bits['key'] ) ) : '',
$is_vagrant_ssh ? '-o StrictHostKeyChecking=no' : '',
$is_vagrant_ssh ? '-o UserKnownHostsFile=/dev/null' : '',
$is_stdout_tty ? '-t' : '-T',
WP_CLI::get_config( 'debug' ) ? '-vvv' : '-q',
];
Expand Down
Loading