Python3:面料2.4.0 ProxyJump和ssh_config中

问题描述 投票:3回答:1

documentation叶想使用ssh_config中时,很多有待改进。有人可以提供的概念证明代码如何实际导入ssh_config中?

要添加到我缺乏了解,我也不清楚为什么,因为它出现在我的ssh_config中加载了下面的代码无法正常工作。进入主机C上的唯一方法是通过主机B进入主机B上的唯一途径是通过我使用ProxyJump主机A.。

非工作示例:

>>> from fabric import Connection
>>> c = Connection('HOST_C')
>>> print(c)
<Connection host=HOST_C gw=proxyjump>
>>> print(c.ssh_config)
{'serveraliveinterval': '60', 'tcpkeepalive': 'yes', 'stricthostkeychecking': 'no', 'forwardagent': 'yes', 'proxyjump': 'HOST_A,HOST_B', 'hostname': 'HOST_C'}
>>> c.run('hostname')
Secsh channel 0 open FAILED: open failed: Administratively prohibited
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-3>", line 2, in run
  File "/Users/username/code/fabric/venv/lib/python3.7/site-packages/fabric/connection.py", line 29, in opens
    self.open()
  File "/Users/username/code/fabric/venv/lib/python3.7/site-packages/fabric/connection.py", line 608, in open
    kwargs["sock"] = self.open_gateway()
  File "/Users/username/code/fabric/venv/lib/python3.7/site-packages/fabric/connection.py", line 640, in open_gateway
    self.gateway.open()
  File "/Users/username/code/fabric/venv/lib/python3.7/site-packages/fabric/connection.py", line 608, in open
    kwargs["sock"] = self.open_gateway()
  File "/Users/username/code/fabric/venv/lib/python3.7/site-packages/fabric/connection.py", line 655, in open_gateway
    src_addr=("", 0),
  File "/Users/username/code/fabric/venv/lib/python3.7/site-packages/paramiko/transport.py", line 944, in open_channel
    raise e
paramiko.ssh_exception.ChannelException: (1, 'Administratively prohibited')

工作示例:

>>> from fabric import Connection
>>> d = Connection('HOST_C', gateway=Connection('HOST_B', gateway=Connection('HOST_A')))
>>> print(d)
<Connection host=HOST_C gw=proxyjump>
>>> print(d.ssh_config)
{'serveraliveinterval': '60', 'tcpkeepalive': 'yes', 'stricthostkeychecking': 'no', 'forwardagent': 'yes', 'proxyjump': 'HOST_A,HOST_B', 'hostname': 'HOST_C'}
>>> d.run('hostname')
HOST_C
<Result cmd='hostname' exited=0>

在一个不相关的音符,如蟒蛇3.7.1的,我收到的paramiko与下面的错误。该加密包是2.5版本。为什么这可能发生的任何见解?

/Users/username/code/virtenv3/lib/python3.7/site-packages/paramiko/ecdsakey.py:164: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
  self.ecdsa_curve.curve_class(), pointinfo
/Users/username/code/virtenv3/lib/python3.7/site-packages/paramiko/kex_ecdh_nist.py:39: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
  m.add_string(self.Q_C.public_numbers().encode_point())
/Users/username/code/virtenv3/lib/python3.7/site-packages/paramiko/kex_ecdh_nist.py:96: CryptographyDeprecationWarning: Support for unsafe construction of public numbers from encoded data will be removed in a future version. Please use EllipticCurvePublicKey.from_encoded_point
  self.curve, Q_S_bytes
/Users/username/code/virtenv3/lib/python3.7/site-packages/paramiko/kex_ecdh_nist.py:111: CryptographyDeprecationWarning: encode_point has been deprecated on EllipticCurvePublicNumbers and will be removed in a future version. Please use EllipticCurvePublicKey.public_bytes to obtain both compressed and uncompressed point encoding.
  hm.add_string(self.Q_C.public_numbers().encode_point())
python python-3.x fabric
1个回答
5
投票
© www.soinside.com 2019 - 2024. All rights reserved.