断开与ssh2_connect()的连接

时间:2011-04-28 14:20:13

标签: php ssh disconnect

我已经使用ssh2_connect通过ssh2连接到服务器,但是我没有看到任何方法in the manpages我应该如何结束连接。

在断开连接之前,我并不是在等待脚本结束的粉丝。

我可以使用fclose吗?这听起来不对......

3 个答案:

答案 0 :(得分:24)

只需unset($connection)您的连接变量或ssh2_exec($connection, 'exit');即可。

你可以做以下事情,以便更有说服力!

ssh2_exec($connection, 'exit');
unset($connection);

答案 1 :(得分:1)

如果您使用phpseclib, a pure PHP SSH implementation,则可以执行$ssh->disconnect()。 phpseclib的析构函数调用它,但你也可以手动调用它。

答案 2 :(得分:-3)

ssh2_exec('logout')会杀死你的会话......

相关问题