From 4735f0c51ed8cd9b7e3e3658fed950e0d5bd67fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 22 Jul 2017 16:35:28 -0300 Subject: [PATCH] Tweak host port --- src/Runtime/Runtime.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Runtime/Runtime.php b/src/Runtime/Runtime.php index 5c3304b..f28e03f 100644 --- a/src/Runtime/Runtime.php +++ b/src/Runtime/Runtime.php @@ -457,12 +457,16 @@ class Runtime */ public function getSSHConfig() { - $sshConfig = $this->getEnvOption('ssh', ['flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']); + $sshConfig = $this->getEnvOption('ssh', ['port' => 22, 'flags' => '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no']); - if (!array_key_exists('port', $sshConfig)) { + if ($this->getHostPort() !== null) { $sshConfig['port'] = $this->getHostPort(); } + if (!array_key_exists('port', $sshConfig)) { + $sshConfig['port'] = '22'; + } + if (!array_key_exists('flags', $sshConfig)) { $sshConfig['flags'] = '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'; } @@ -478,7 +482,7 @@ class Runtime public function getHostPort() { $info = explode(':', $this->getWorkingHost()); - return isset($info[1]) ? $info[1] : '22'; + return isset($info[1]) ? $info[1] : null; } /**