0

I am trying to SSH into a switch in order to retrieve the CPU Usage from it. However, after running the code, the output is [ ]. I am using Paramiko on Python 3.9.

# Establish Connection

import paramiko

# Change IP & Port Accordingly
ip='127.0.0.1'
port=22

# Change username & password Accordingly
username='usr'
password='pswd'


ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,port,username,password)

# Send Commands

cmd = 'show cpu-usage'

stdin,stdout,stderr=ssh.exec_command(cmd)
outlines=stdout.readlines()
resp=''.join(outlines)
print(stdout.readlines()) # Output

0 Answers0