I\'m working on a script (python 2.7) that is wotking with a remote device running Cisco IOS, so I need to execute a lot of commands through ssh. Few commands have no output
I think what you need is invoke_shell()
. For example:
ssh = paramiko.SSHClient()
... ...
chan = ssh.invoke_shell() # starts an interactive session
chan.send('command 1\r')
output = chan.recv()
chan.send('command 2\r')
output = chan.recv()
... ...
The Channel
has many other methods. You can refer to the document for more details.
You need to properly chain the commands together, as in a shell script:
stdin, stdout, stderr = ssh.exec_command('''
command1
&& command2
&& command3
''')