paramiko redirect tcpdump text to file generating a binary file

Viewed 19

I can run

sudo nohup tcpdump -i any tcp src port 1234 -A -tttt  -n -s 0 > test.log &

in a ssh shell and the test.log is a text file.

But I run it with python and paramiko:

def get_client(user_name, public_ip):
    client = paramiko.SSHClient()
    pk = paramiko.RSAKey.from_private_key_file("/home/user/.ssh/id_rsa")
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(
        hostname=public_ip,
        username=user_name,
        pkey=pk
    )
    return client


client = get_client(user_name, public_ip)
cmd = "sudo nohup tcpdump -i any tcp src port 1234 -A -tttt  -n -s 0 > test.log &"
stdin, stdout, stderr = client.exec_command(cmd)
stdin.close()
client.close()

Then less test.log in a ssh shell, it says

"test.log" may be a binary file.  See it anyway?

Why? Or how can I make it?

0 Answers
Related