I am working on converting a tool from Ruby to Python, and the Ruby version uses Net::SSH to connect to a remote host, and send commands and retrieve responses/data. I have
exec_command()
is enough if the SSH server supports running commands (like ssh user@host "cmd; cmd; ..."
. But some SSH servers (e.g. network devices like switches, routers, ...) only supports starting an interactive session. Then you need to use invoke_shell()
which returns a Channel.
Transport and Channel are all SSH terms (other than Paramiko's). See following RFCs for more info: