diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index fc3b1c9e..832c570c 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2101,10 +2101,6 @@ class SSH2 return false; } - if (!is_string($password)) { - throw new \UnexpectedValueException('$password needs to either be an instance of \phpseclib\Crypt\Common\PrivateKey, \System\SSH\Agent, an array or a string'); - } - if (!isset($password)) { $packet = Strings::packSSH2( 'Cs3', @@ -2133,6 +2129,10 @@ class SSH2 } } + if (!is_string($password)) { + throw new \UnexpectedValueException('$password needs to either be an instance of \phpseclib\Crypt\Common\PrivateKey, \System\SSH\Agent, an array or a string'); + } + $packet = Strings::packSSH2( 'Cs3bs', NET_SSH2_MSG_USERAUTH_REQUEST,