Python Paramiko 和 IPV6 SSH [英] Python Paramiko and IPV6 SSH

查看:111
本文介绍了Python Paramiko 和 IPV6 SSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个脚本,使用 SSH 在远程机器上执行一些命令.我为此使用了 paramiko,只要我使用 IPv4 寻址,一切都可以正常工作.我不得不切换 IPv6 地址,但似乎无法连接 Paramiko 客户端.

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')

错误:

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

有没有给paramiko指定ip6地址的例子?

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

推荐答案

您还必须指定接口名称.

You have to specify the interface name as well.

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

以下示例是有效的 IPv6:

Following example is valid IPv6:

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

这篇关于Python Paramiko 和 IPV6 SSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆