php - 从 ssh2_connect() 断开连接

标签 php ssh disconnect

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

我不喜欢在断开连接之前等待脚本结束。

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

最佳答案

只是unset($connection)您的连接变量或 ssh2_exec($connection, 'exit'); 可能会这样做。

为了更有说服力,您可能会执行以下操作!

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

关于php - 从 ssh2_connect() 断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5820089/

相关文章:

java - 如何正确检测 servlet 规范 3 中的客户端断开连接?

PHP 根本不检测连接中止

php - 为 PHP 查询创建 GridView

php - 如何在 Silex 中使用 “render” 在 Twig 中插入 Controller

git - Fedora 33 git pull 或 clone 不再工作和/或 ssh key 不再识别

go - 如何进行简单的 SSH x11 转发

python - 通过本地 ssh 配置 (~/.ssh/config) 的 PyCharm SSH 隧道

php - PDO准备语句问题

php - 在 session 销毁时执行函数

.net - .NET套接字DisconnectAsync任务扩展方法