King wrote:
Hi guys ,
I want to write a script that will check the ssh connection can u suggest me best method to do that apart from ping (telnet ) on the ssh port or nmap i knw that but anything better than this ...
Why do you want to do so? telnet is a neat way for checking it. However if you must use some script then try this python script:
-------------------------------------- #!/usr/bin/env python """ File: sshtest.py Usage: $ python sshtest.py """
import socket,os server='gnu.hbcse' port=22 srv=socket.socket(socket.AF_INET,socket.SOCK_STREAM) try: srv.connect((server,port)) print('port '+str(port)+' @ '+server+' open') srv.close() except Exception: print('port '+str(port)+' @ '+server+' closed') --------------------------------------
-Anurag
-- ----------------------------------------------- __ __ gnu /noo/ n. Ox like antelope; (abbr.) /gnoo/ (recursive acronym) Gnu's Not Unix.