Executing a Command Using the Paramiko on Brocade Switch

I am trying to use Paramiko to SSH on a Brocade switch and execute remote commands. The code is below:

def ssh_connector(ip, userName, passWord, command):
 ssh = paramiko.SSHClient()
 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
 ssh.connect(ip, username=userName, password=passWord, port=22)
 stdin, stdout, stderr = ssh.exec_command(command)
 print stdout.readlines()

ssh_connector(ip, userName, passWord, 'show running-config')

      

When trying to run the code, I am faced with a strange error which is shown below.

Protocol error, does not start with scp!

I don't know the reason for the error or a successful SSH connection. Could you help me with this?

+3


source to share


1 answer


The exec pipe on the Brocade SSH server seems to be implemented to support only commands scp

. Therefore, you cannot use your code with . SSHClient.exec_command

Since you are claiming that you can connect to the switch over "SSH", the "shell" appears to be fully operational.



You should be able to use and write commands to the pipe (= to the shell) using . SSHClient.invoke_shell

Channel.send

channel = ssh.invoke_shell()
channel.send('ls\n')
channel.send('exit\n')

      

+4


source







All Articles