pecl-networking-ssh2 icon indicating copy to clipboard operation
pecl-networking-ssh2 copied to clipboard

ssh2_auth_password Password parameter does not work as expected

Open auth1299 opened this issue 3 years ago • 3 comments

I'm using https://pecl.php.net/package/ssh2 module in PHP. The password parameter is not working as intended.

This Works:

but if I put that code into a function and pass the password into the function ssh2_connect() authentication will fail. Password will only work if I manually supply it in the code. My use case is pulling the password from a database and passing it into a custom function parameter and then pass it to ssh2_connect().

I had the issue on windows PHP 7.4 using the 1.2 SSH2 module I then upgraded to version PHP 8.1 and now using 1.3 SSH2 module on windows. I get the same behavior on both versions.

auth1299 avatar Feb 11 '22 22:02 auth1299

I don't understand, there are some factual errors in the issue you are describing. ssh_connect() has no password parameter.

Can you share both a working and non-working minimal code snippet?

langemeijer avatar Feb 11 '22 22:02 langemeijer

The code snippet does not show for some reason in the above comment.

I meant to say ssh2_auth_password() function.

It seems that if I pull the password from a database and passed it to ssh2_auth_password() function, it will not authenticate but if I hardcode the password as a string into the ssh2_auth_password() function, it works. I've made sure to format the database string as a (string)$password. Is there a way to debug exactly what the ssh2_auth_password() is doing? I can't seem to find any documentation any where on how to enable debug logging for ssh2_auth_password().

auth1299 avatar Feb 14 '22 14:02 auth1299

Can you reproduce the issue if you hard-code the password in the file, but use concatenation to build the string? eg:

ssh2_auth_password($session, 'user' . 'name', 'welcome' . '123');

langemeijer avatar Feb 14 '22 15:02 langemeijer

I'm happy to work forward with you in fixing this issue, but you are giving me nothing to work with. For now I can only follow Occam's razor and assume you've made some trivial error in your code somehow.

Please provide me with snippet of code that allows me to repeat your issue and we can move further.

langemeijer avatar Apr 15 '23 12:04 langemeijer