|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #56516 Only one log in possible per SSH connection
Submitted: 2005-08-29 09:59 UTC Modified: 2012-06-20 14:31 UTC
From: pear dot 20 dot fab at spamgourmet dot com Assigned:
Status: Not a bug Package: ssh2 (PECL)
PHP Version: 5.0.3 OS: Fedora Core 4
Private report: No CVE-ID: None
 [2005-08-29 09:59 UTC] pear dot 20 dot fab at spamgourmet dot com
unfortunately it is not possible to re-use a SSH connection for several log ins (authentications). This would be *very* useful because it takes ages to establish a ssh connection, so one could save a lot of time if it were possible to re-login via ssh2_auth_password().
Btw, the server hangs up if one tries to re-authenticate a second time.

Reproduce code:
$con = ssh2_connect("server");
ssh2_auth_password($con, 'username', 'secret');
ssh2_auth_password($con, 'username', 'secret');
echo "program will never reach this point";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-29 10:02 UTC] pear dot 20 dot fab at spamgourmet dot com
PS: I'm using PHP 5.04 and SSH2 0.9
 [2005-08-29 10:05 UTC] pear dot 20 dot fab at spamgourmet dot com
 [2008-05-08 22:56 UTC] volkirik at yahoo dot com dot tr

LibSSH2 0.18, PECL/ssh2 0.10

I could re-authenticate second time with following code:

Reproduce code:
$ssh2_host = '';
$ssh2_user = 'volkan';

$con=ssh2_connect($ssh2_host, 22);

if ($con == false){
	die('conn err');

if (ssh2_auth_password($con, $ssh2_user, 'wrongpass'))
	echo 'Auth 1 SUCCESS'."\n";
} else{
	echo 'Auth 1 failed.';

	if (ssh2_auth_password($con, $ssh2_user, 'correctpass'))
		echo 'Auth 2 SUCCESS'."\n";
	} else {
		echo 'Auth 2 failed.'."\n";

Auth 1 failed.
 [2012-06-13 21:08 UTC]
The libssh2 library does not support re-authenticate.

I asked the libssh2 developers if this could be possible in the future. I doubt 
it though. I don't think it's possible to switch user with the ssh protocol.

Do you know of any other ssh client that does this?
 [2012-06-13 21:08 UTC]
-Status: Open +Status: Feedback
 [2012-06-20 14:31 UTC]
As I expected: neither the libssh2 library or the ssh protocol support this.

It can't be done.
 [2012-06-20 14:31 UTC]
-Status: Feedback +Status: Not a bug
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jul 27 00:01:25 2021 UTC