Python Paramiko and IPV6 SSH

ぃ、小莉子 提交于 2019-12-11 03:04:07

问题


I have to write a script that executes some commands on a remote machine using SSH. I had used paramiko for this and everything worked as long as I used IPv4 addressing. I had to switch IPv6 addressing and I can't seem to get Paramiko client to connect.

import paramiko
s = paramiko.SSHClient()
ip6_addr = 'fe80::1112:bcde:789a:1234'
s.connect (ip6_addr, username='foo', password='bar')

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/paramiko/client.py", line 290, in connect
    sock.connect(addr)
  File "<string>", line 1, in connect
socket.error: [Errno 22] Invalid argument

Is there an example on how to specify the ip6 address to paramiko?


回答1:


You have to specify the interface name as well.

ip6_addr = 'fe80::1112:bcde:789a:1234%<interface>'

Following example is valid IPv6:

ip6_addr = 'fe80::1112:bcde:789a:1234%eth0'



回答2:


On my Python2.7.9 (which is also not the latest) and paramiko-1.15.2, I have no Problems.

Have you tried upgrading paramiko?

pip install --upgrade paramiko

EDIT: Another idea, maybe your kernel does not support ipv6. How to test from userspace if the kernel supports IPv6?



来源:https://stackoverflow.com/questions/31956313/python-paramiko-and-ipv6-ssh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!