Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to specify/override ssh default-command #5328

Open
wants to merge 1 commit into
base: 11.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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'