Incognito
Incognito

Reputation: 20765

Disconnect from ssh2_connect()

I've connected over ssh2 using ssh2_connect to a server, but I don't see any method in the manpages for how I should end the connection.

I'm not exactly a fan of waiting for a script to end before I disconnect.

Can I use fclose? That doesn't sound right...

Upvotes: 19

Views: 24103

Answers (3)

user734976
user734976

Reputation:

If you were using phpseclib, a pure PHP SSH implementation, you could do $ssh->disconnect(). phpseclib's destructor calls it but you could call it manually as well.

Upvotes: 1

Flask
Flask

Reputation: 4996

ssh2_exec('logout') should kill your session…

Upvotes: -4

Treffynnon
Treffynnon

Reputation: 21563

Just unset($connection) your connection variable or ssh2_exec($connection, 'exit'); might do it.

You could probably do the following in order to be even more convincing!

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

Upvotes: 25

Related Questions