0

I´m trying the simplest way to make a SSH connection and execute a command with paramiko

import paramiko, base64
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('10.50.0.150', username='XXXXX', password='XXXXXX')
stdin, stdout, stderr = client.exec_command('show performance -type host-io')
for line in stdout:
    print '... ' + line.strip('\n')
client.close()

------------ERROR-----------------------

Traceback (most recent call last):
  File "a.py", line 5, in <module>
    stdin, stdout, stderr = client.exec_command('show performance -type host-io')
  File "/usr/lib/python2.6/site-packages/paramiko-1.10.1-py2.6.egg/paramiko/client.py", line 374, in exec_command
    chan.exec_command(command)
  File "/usr/lib/python2.6/site-packages/paramiko-1.10.1-py2.6.egg/paramiko/channel.py", line 218, in exec_command
    self._wait_for_event()
  File "/usr/lib/python2.6/site-packages/paramiko-1.10.1-py2.6.egg/paramiko/channel.py", line 1122, in _wait_for_event
    raise e
EOFError

If i execute this code changing the command it works and to another computer, this command works fine via SSH interative shell.

Any idea ?

2
  • 1
    Log in to the system (which raise the exception) and run the command. What do you get? Commented Jul 31, 2013 at 7:54
  • I get the expected results if I use linux ssh command. The ssh server is Remote protocol version 1.99, remote software version IPSSH-6.7.0 Commented Jul 31, 2013 at 8:09

1 Answer 1

1

After client.connect(. . .) you need to use this command

session = client.get_transport().open_session()

then use session.exec_command(. . .).

Sign up to request clarification or add additional context in comments.

1 Comment

I have a similar problem. The SSH command I am launching is long running (several minutes). What is the reason to create a session as you have shown?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.