Skip to content Skip to sidebar Skip to footer

Python Paramiko Ssh Run Command

I want to run simple command just for test ssh connection. There is an error about stdin/out/err. Code and error mesage is below. Can someone help me ? Code import paramiko import

Solution 1:

Since you are logged out from the terminal it is giving a EOFError AFAIK you can just close the connection it will automatically close your session there.

Consider the following code

import paramiko
import sys

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('x.x.x.x', port=2222, username='user', password='pass')
stdin, stdout, stderr = client.exec_command('ls')

printstdout
client.close()

Post a Comment for "Python Paramiko Ssh Run Command"