PHP: Hypertext Preprocessor (original) (raw)
ssh2_disconnect
(PECL ssh2 >= 1.0)
ssh2_disconnect — Close a connection to a remote SSH server
Description
Parameters
session
An SSH connection link identifier, obtained from a call tossh2_connect().
Return Values
Returns [true](reserved.constants.php#constant.true)
on success or [false](reserved.constants.php#constant.false)
on failure.
Found A Problem?
6 years ago
`ssh2_disconnect(...) requires at least PHP 7 (as it requires PECL ssh2 >= 1.0, which the PECL documentation on https://pecl.php.net/package/ssh2 states: "ssh2 1.0 and above is PHP 7 only").
For PHP 5.x similar functionality, try setting the ssh2_connect session variable to null, or unsetting it completely - this should allow PHP's garbage collection close the connection.
Example:
$session=ssh2_connect(...); // open connection
// code here to use connection session=null;unset(session = null; unset(session=null;unset(session); // close connection
`
4 years ago
`This function worked fine as long as I didn't use any ssh2_sftp* stuff. As soon as I did, the connection (from my webserver to my browser) was closed without any warning/error in any of the logfiles. So, this won't work
sftp=ssh2sftp(sftp = ssh2_sftp(sftp=ssh2sftp(connection); ssh2_disconnect(); // Causes the connection to be reset ?>while this works
sftp=ssh2sftp(sftp = ssh2_sftp(sftp=ssh2sftp(connection); connection=null;unset(connection = null; unset(connection=null;unset(connection); ?>`
2 years ago
`If you derive an sftp connection from an ssh connection you must close the sftp connection before closing the ssh connection if you use ssh2_dissconnect. In other words:
sshcon=ssh2connect(ssh_con=ssh2_connect(sshcon=ssh2connect(sftp_server); ssh2_auth_password($ssh_con, sftpuser,sftp_user, sftpuser,sftp_pass); scpcon=ssh2sftp(scp_con=ssh2_sftp(scpcon=ssh2sftp(ssh_con);# do stuff with scpconssh2disconnect(scp_conssh2_disconnect(scpconssh2disconnect(scp_con); ssh2_disconnect($ssh_con); ?>`