Skip to content

Commit

Permalink
Allow to specify ssh default-command
Browse files Browse the repository at this point in the history
  • Loading branch information
ceesgeene committed Dec 5, 2022
1 parent ba4f1ce commit d9e265c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/using-drush-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ ssh:
# password authentication, and is included here, so you may add additional
# parameters without losing the default configuration.
options: '-o PasswordAuthentication=no'
# Specify the default command used when `drush ssh` is invoked without arguments.
default-command: ['bash', '-l']
# Enable tty mode when using default command.
default-command-tty: true
# This string is valid for Bash shell. Override in case you need something different. See https://github.com/drush-ops/drush/issues/3816.
pipefail: 'set -o pipefail; '

Expand Down
4 changes: 4 additions & 0 deletions examples/example.drush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ ssh:
# password authentication, and is included here, so you may add additional
# parameters without losing the default configuration.
options: '-o PasswordAuthentication=no'
# Uncomment to override the default command used when `drush ssh` is invoked without arguments.
# default-command: ['bash', '-l']
# Uncomment to override tty mode when using default command.
# default-command-tty: true
# This string is valid for Bash shell. Override in case you need something different. See https://github.com/drush-ops/drush/issues/3816.
pipefail: 'set -o pipefail; '
5 changes: 2 additions & 3 deletions src/Commands/core/SshCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ public function ssh(array $code, $options = ['cd' => self::REQ]): void
$alias = $this->siteAliasManager()->getSelf();

if (empty($code)) {
$code[] = 'bash';
$code[] = '-l';
$code = $this->getConfig()->get('ssh.default-command', ['bash', '-l']);

// We're calling an interactive 'bash' shell, so we want to
// force tty to true.
$options['tty'] = true;
$options['tty'] = $this->getConfig()->get('ssh.default-command-tty', true);
}

if ((count($code) == 1)) {
Expand Down
1 change: 1 addition & 0 deletions tests/functional/resources/alias-fixtures/example.site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ live:
uri: https://example.com
ssh:
options: '-o PasswordAuthentication=example'
default-command: ['sh', '-l']
paths:
drush-script: '/example/path/to/drush'

0 comments on commit d9e265c

Please sign in to comment.