Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko,socks
- import time
- import csv
- import getpass
- import fileinput
- import socket
- def enable_mode(SSH):
- # Enter privileged mode
- SSH.send("enn")
- time.sleep(1)
- SSH.send(ENABLE + "n")
- # Clear the buffer on screen
- output = SSH.recv(1000)
- def disable_paging(SSH):
- # Disable Paging on Device
- SSH.send("term len 0n")
- time.sleep(1)
- # Clear buffer on the screen
- output = SSH.recv(1000)
- host, port = '10.179.220.11', 1080 #<-(Not sure ,if this host IP
- should be 127.0.0.1 or the actual jump box server IP)
- # Set up your proxy information for this socket
- sock=socks.socksocket()
- sock.set_proxy(
- proxy_type=socks.SOCKS5,
- addr=host,
- port=port, # <- should this port be 22 or 1080?
- )
- # Connect the socket
- sock.connect((host, port))
- # Create your Paramiko Transport
- transport = paramiko.Transport(sock)
- transport.connect(
- username='xyz', #<- should this be jump box username?
- password='ABC', #<- should this be jump box password?
- )
- ssh_pre = paramiko.SSHClient()
- ssh_pre.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- USERNAME = input("Please input your username:")
- PASSWORD = getpass.getpass("Please input password for" +" " + USERNAME +
- ":")
- # Prompt user for enable password
- ENABLE = getpass.getpass("Please input the enable password:")
- ssh_pre.connect('10.1.1.1', username = USERNAME, password = PASSWORD,
- sock=sock)
- # Use invoke_shell to establish an interactive session
- ssh = ssh_pre.invoke_shell()
- # Enable mode
- enable_mode(ssh)
- # Turn off paging
- disable_paging(ssh)
- ssh.send("show versionn")
- time.sleep(3)
- transport.close()
Add Comment
Please, Sign In to add comment