我在建立 sshtunnel 连接时遇到问题,因为服务器不支持 rsa-sha2-512 公钥算法。我无法更改服务器上的任何内容。我可以使用 paramiko 进行连接,但前提是我使用disable_algorithms 配置参数。当我使用 sshtunnel 时,我不知道如何调整 paramiko disable_algorithms 的配置。
import sshtunnel
with sshtunnel.open_tunnel(
(REMOTE_SSH_IP, 22),
ssh_username='username',
ssh_pkey='~/.ssh/id_rsa',
remote_bind_address=('127.0.0.1', 8080)
) as tunnel:
print('DONE')
Run Code Online (Sandbox Code Playgroud)
如果我使用 paramiko 打开到同一台机器的 ssh 会话,使用相同的公钥,我就可以毫无问题地进行连接,但只有当我在 SSHClient 配置中设置disabled_algorithms 时。
disabled_algorithms=dict(pubkeys=["rsa-sha2-512", "rsa-sha2-256"])
Run Code Online (Sandbox Code Playgroud)
如果我可以以某种方式在 sshtunnel 内设置相同的disabled_algorithms,那么我认为这可以解决我的问题。我尝试过使用 ~/.ssh/config 但是 sshtunnel 似乎不支持它,即使我在 open_tunnel 配置中设置了路径。我仍然遇到同样的错误。ssh_config_file="~/.ssh/config"
提前致谢。
python 3.10.2 标准输出:
ERROR:sshtunnel.SSHTunnelForwarder:Could not open connection to gateway
Traceback (most recent call last):
File "/Users/blah/Files/Devel/TXPro/inventory/inventory/cli/test.py", line 26, in <module>
with sshtunnel.open_tunnel(
File "/Users/blah/.pyenv/versions/3.10.2/lib/python3.10/site-packages/sshtunnel.py", line 1608, in __enter__
self.start()
File "/Users/blah/.pyenv/versions/3.10.2/lib/python3.10/site-packages/sshtunnel.py", line …Run Code Online (Sandbox Code Playgroud)