Disconnect from ssh2_connect()

Incognito picture Incognito · Apr 28, 2011 · Viewed 22.6k times · Source

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...

Answer

Treffynnon picture Treffynnon · Apr 28, 2011

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);