Sample code for 30+ languages & platforms
PHP Extension

Check SSH Connection (IsConnected)

Demonstrates how to check to see if the connection to the SSH server exists.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

$ssh = new CkSsh();

// Connect to an SSH server:
$success = $ssh->Connect('192.168.1.209',22);
if ($success != true) {
    print $ssh->lastErrorText() . "\n";
    exit;
}

// Is the last known state "connected"?
$connected = $ssh->get_IsConnected();
if ($connected == true) {
    // Verify for sure by sending an ignore message.
    $connected = $ssh->SendIgnore();
}

print 'connected = ' . $connected . "\n";

// Disconnect.
$ssh->Disconnect();

// Am I still connected?
$connected = $ssh->get_IsConnected();
print 'connected = ' . $connected . "\n";

?>