Uncategorized

ssh – Python Paramiko – problems with sending “iperf -s” to Linux server


I need to send the command iperf -s to a Linux server using a Python program. The command is not sent. The chronology of problems is as follows:

  1. I am sending the command iperf -s to the server. Nothing happens, the program freezes (I don’t stop the program).
  2. I use the netstat -tupln to check the processes. A process iperf is created on the server, but nothing is happened.
  3. If I kill this process with a sudo kill -9 <PID>, the program outputs the traditional output when the iperf -s is executed and the program exits.
  4. If I check the processes again, the iperf process is not there.

Here’s my code:

remote_server = "172.22.94.171"
client = paramiko.client.SSHClient()
username = "useruser"
password = "password"

client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(remote_server, port=22, username=username, password=password)

stdin, stdout, stderr = client.exec_command('sudo iperf -s', get_pty=True)

stdin.write(password+'\n')

print(stdout.readlines())



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *