1
votes

I am working with Paramiko 2.7.1, using a simple client implementation for running commands on remote SSH servers.

On most of my hosts, it works great. Input commands go out, output (if exists) comes back.

One specific type of host (an IBM VIOS partition to be precise) is giving me headaches in that the commands execute, but the output is always empty. I have used PuTTY in an interactive session to log all SSH packets and check for any differences and, at least during an interactive session, no differences present between a working and a non-working host. I have enabled Paramiko logging with:

basicConfig(level=DEBUG)
logging.getLogger("paramiko").setLevel(logging.DEBUG)
log_to_file('ssh.log')

But the output doesn't dump each packet. I have done a search for any parameters or methods that would dump those packets but I've come up empty. Wireshark is not an option since we are talking about an encrypted connection. I would prefer to keep using exec_command instead of having to refactor everything and adapt to using an SSH shell. So, in the end. Is there any way to dump the entire SSH session with Paramiko? I can handle either SSH packets or raw data.


Edit 1: I have remembered that PuTTY's plink.exe does ssh exec commands, so I used it to compare both SSH server's output and stumbled onto the solution to my base problem: https://www.ibm.com/support/pages/unable-execute-commands-remotely-vio-server-padmin-user-ssh
Still, I'd rather have captured the session with Paramiko, since I will not always be able to simulate with other tools...

1
This looks like XY problem. I suggest your ask a question about your actual problem rather than about what you think will help you do debug the problem (I do not think that packet debugging would help you).Martin Prikryl
I appreciate the comment, but even though my actual problem IS defined, what I wanted to know was how to debug the SSH session with paramiko. Having cut my teeth in assembler for microcontrollers I'm used to going deep to debug problems and not being able to compare the sessions irks me. On the bright side, not 10 minutes went by that I remembered that putty has plink.exe that also does ssh exec commands and I can use it to debug. So MY problem right now has been solved with another tool, but I still would like to know how to log the ssh packets. There IS a difference in output between serversRoberto Jose Etcheverry Romero

1 Answers

0
votes

In addition to enabling logging, call Transport.set_hexdump():

client.get_transport().set_hexdump(True)

Regarding your original problem, see also:
Command executed with Paramiko does not produce any output