Posts

Showing posts with the label paramiko

Python Invokeshell Multiple commands Cisco

Python Invokeshell Multiple commands Cisco I'm having issues with my script which reads from an ip from the text file. Process the IP through ssh into the device. Executes three show commands. The problem I'm having is I would think the double authentication, however when I modify the script with the authentication all it does is print the command on the line, but doesn't execute the command. import paramiko import getpass import io import os import time # *****Open Plain Text #f = open ("chkpt.txt") f = open ("ciscoasa.txt") # *****Read & Store into Variable ip =(f.read().splitlines()) f.close() # *****Username Credentials username = raw_input("Please Enter Username:") # *****Password Options password = getpass.getpass("Please Enter Password:") # ***** Name of File #name = raw_input("Please Name Your File:") client=paramiko.SSHClient() def connect_ssh(ip): try: client.load_system_host_keys() client....

paramiko-expect timeout is happening after executing the command

paramiko-expect timeout is happening after executing the command Can someone help me why timeout is happening after executing the command .I am trying to SSH to a machine and execute a command.I want to store the result of the executed command . I have referred paramiko-timeout but i didn't get my expected result. import traceback try: import paramiko except ImportError: raise Exception("Please install paramiko , pip install paramiko") import pexpect from paramiko_expect import SSHClientInteraction def main(): HOSTNAME = "minion5.net" USERNAME = "root" PASSWORD = "help@432" PROMPT = "root@*:~$s+" try: client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname=HOSTNAME, username=USERNAME, password=PASSWORD) with SSHClientInteraction(client, timeout=20, display=True) as interact: ...