CkPython
CkPython
Check SSH Connection (IsConnected)
Demonstrates how to check to see if the connection to the SSH server exists.Chilkat CkPython Downloads
import sys
import chilkat
success = False
ssh = chilkat.CkSsh()
# Connect to an SSH server:
success = ssh.Connect("192.168.1.209",22)
if (success != True):
print(ssh.lastErrorText())
sys.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 = " + str(connected))
# Disconnect.
ssh.Disconnect()
# Am I still connected?
connected = ssh.get_IsConnected()
print("connected = " + str(connected))