I got an issue when using paramiko to ssh (user+pass, no pubkey used) to a apc pdu(Net Mgmt Card).The same code works if it connects to a cisco switch. Is it something related to low python version? or I should tune the ssh parameters for this particular low profile device (apc pdu)? Any of your suggestion is highly appreciated!
code snippet
import paramiko
def ssh_connect(ip,user,password,comm):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip,username=user,password=password,allow_agent=False,look_for_keys=False)
session = client.get_transport().open_session()
if session.active:
stdin, stdout, stderr = client.exec_command(comm)
print(stdout.read().decode())
return
ssh_connect('10.1.1.10','bob.lee','abcdefg','whoami')
Errors:
/home/boblee/.local/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.hazmat.backends import default_backend
Traceback (most recent call last):
File "pdu.py", line 14, in <module>
ssh_connect('10.1.1.10','boblee','abcdefg','whoami')
File "pdu.py", line 8, in ssh_connect
stdin, stdout, stderr = client.exec_command(comm)
File "/home/boblee/.local/lib/python2.7/site-packages/paramiko/client.py", line 510, in exec_command
chan = self._transport.open_session(timeout=timeout)
File "/home/boblee/.local/lib/python2.7/site-packages/paramiko/transport.py", line 879, in open_session
timeout=timeout,
File "/home/boblee/.local/lib/python2.7/site-packages/paramiko/transport.py", line 1006, in open_channel
raise e
EOFError