我用以下ssh2函数成功连接了sftp,也可以正常操作,但是我找不到手动断开的函数,这样的话只能等超时,会给sftp
服务器带来负担@ssh2_connect($host, $port);
@ssh2_auth_password($this->connection, $username, $password))
@ssh2_sftp($this->connection);有没有办法等我操作完了直接关闭连接?
服务器带来负担@ssh2_connect($host, $port);
@ssh2_auth_password($this->connection, $username, $password))
@ssh2_sftp($this->connection);有没有办法等我操作完了直接关闭连接?
类似于数据库的连接?
<?php
/* Notify the user if the server terminates the connection */
function my_ssh_disconnect($reason, $message, $language) {
printf("Server disconnected with reason code [%d] and message: %s\n",
$reason, $message);
}$methods = array(
'kex' => 'diffie-hellman-group1-sha1',
'client_to_server' => array(
'crypt' => '3des-cbc',
'comp' => 'none'),
'server_to_client' => array(
'crypt' => 'aes256-cbc,aes192-cbc,aes128-cbc',
'comp' => 'none'));$callbacks = array('disconnect' => 'my_ssh_disconnect');$connection = ssh2_connect('shell.example.com', 22, $methods, $callbacks);
if (!$connection) die('Connection failed');
?>