Feb-06-2018, 06:07 AM
import socket socket.setdefaulttimeout(5) import paramiko import sys import threading import os import time ip = '10.124.117.12' user = 'ops' passwd = 'BN123' ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: ssh.connect(ip,username=user,password=passwd, timeout=5) print "Connected to %s" % ip time.sleep(5) connection = ssh.invoke_shell() stdin, stdout, stderr = ssh.exec_command("show chassis\n") result = stdout.read().decode('ascii').strip("\n") ssh.close() print result except (socket.error,paramiko.AuthenticationException,paramiko.SSHException) as message: print "ERROR: SSH connection to "+ip+" failed: " +str(message) sys.exit(1) except paramiko.SSHException: print "[-] SSH Exception! ..."showing as below error
Connected to 10.124.117.12 No handlers could be found for logger "paramiko.transport" ERROR: SSH connection to 10.124.117.12 failed: (1, 'Administratively prohibited')however I am able to telnet from command prompt
ssh -l ops 10.124.117.12
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! **** WARNING: UNAUTHORISED ACCESS PROHIBITED **** !
! You are about to log on to a proprietary system where access is provided, !
! by the Owner of the system, only to authorized users. !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[email protected]'s password:
*A:BNG_01# logout