Форум сайта python.su
Суть. Есть задача обходить всякое разное оборудование и выполнять на нем некие операции. Волевым решением было принято использовать ssh. Все происходит штатно до тех пор, пока среди цисок не затесалось поделие HP ProCurve. И началось.
>>> import paramiko >>> ssh=paramiko.SSHClient() >>> paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG) >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) >>> ssh.connect('switchname',username='admin',password='admin') DEBUG:paramiko.transport:starting thread (client mode): 0x6f8ca10L INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_3.7.1p2) DEBUG:paramiko.transport:kex algos:['diffie-hellman-group-exchange-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa'] client encrypt:['des', '3des-cbc'] server encrypt:['des', '3des-cbc'] client mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none'] server compress:['none'] client lang:[''] server lang:[''] kex follows?False DEBUG:paramiko.transport:Ciphers agreed: local=3des-cbc, remote=3des-cbc DEBUG:paramiko.transport:using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local 3des-cbc, remote 3des-cbc; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none DEBUG:paramiko.transport:Switch to new keys ... DEBUG:paramiko.transport:Adding ssh-rsa host key for sar02-7-sw01: b1dc25333ef25e43abd3ba1598ab7800 DEBUG:paramiko.transport:Trying SSH agent key 379d578d7069d19e3ccdab2c8800c5f7 DEBUG:paramiko.transport:userauth is OK DEBUG:paramiko.transport:Authentication type (publickey) not permitted. DEBUG:paramiko.transport:Allowed methods: ['password'] DEBUG:paramiko.transport:Trying discovered key 379d578d7069d19e3ccdab2c8800c5f7 in /home/admin/.ssh/id_rsa DEBUG:paramiko.transport:userauth is OK DEBUG:paramiko.transport:Authentication type (publickey) not permitted. DEBUG:paramiko.transport:Allowed methods: ['password'] DEBUG:paramiko.transport:userauth is OK INFO:paramiko.transport:Authentication (password) successful! >>> stdin,stdout,stderr=ssh.exec_command('show version') DEBUG:paramiko.transport:[chan 1] Max packet in: 34816 bytes DEBUG:paramiko.transport:[chan 1] Max packet out: 32768 bytes INFO:paramiko.transport:Secsh channel 1 opened. DEBUG:paramiko.transport:[chan 1] EOF sent (1) DEBUG:paramiko.transport:EOF in transport thread DEBUG:paramiko.transport:EOF in transport thread Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 364, in exec_command chan.exec_command(command) File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 213, in exec_command self._wait_for_event() File "/usr/lib/python2.7/dist-packages/paramiko/channel.py", line 1084, in _wait_for_event raise e paramiko.SSHException: Channel closed.
Отредактировано avb (Июль 25, 2013 14:02:20)
Офлайн
Доктор, что я делаю не так?
Офлайн
Спасибо, будем просвещаться.
Офлайн