只需使用unset($connection)
或ssh2_exec($connection, 'exit');
来关闭连接变量即可。
为了更加令人信服,你还可以执行以下操作!
ssh2_exec($connection, 'exit');
unset($connection);
ssh2_exec()
дёҚжҳҜиө„жәҗпјҲжҲ–иҝ”еӣһfalse
пјүж—¶жүҚиғҪжү§иЎҢunset()
гҖӮ - Alix Axelssh2_exec($connection,'exit')或unset($connection);
应该可以。 - Alix Axelssh2_exec($conn, 'exit')
和 ssh2_exec($conn, 'logout')
不会 终止会话。它们只是从用于执行命令的临时 shell 中退出。SSH 会话仍然存在。 - Jesse$ssh->disconnect()
。phpseclib 的析构函数会调用它,但您也可以手动调用它。ssh2_exec('logout')
应该会结束您的会话...
system('kill -9 ' . getmypid())
,尽管看起来很丑,但在这种情况下是有效的。 - Aaron Miller
fclose()
应该与ssh2_exec()
和ssh2_shell()
调用结合使用,但我不认为它适用于ssh2_connect()
。 - Alix Axel