【发布时间】:2017-12-26 02:09:15
【问题描述】:
我无法理解(即使在阅读了几篇专门讨论 ssh Tunelling 的文章之后)CLI ssh 命令的哪些参数在此脚本中的位置。 基本上我必须连接到某个服务器(我称之为 'ssh_tunnel_host:22'),而不是使用此隧道连接到 db_host。
with SSHTunnelForwarder(
('ssh_tunnel_host', 22),
ssh_username="ssh_username",
ssh_pkey="/somepath/id_rsa",
local_bind_address=('0.0.0.0', 1234),
remote_bind_address=('127.0.0.1', 3306)
) as tunnel:
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('127.0.0.1', 1234)
db_connection = pymysql.connect(host=db_host, port=3306, db='mysql', user='user',
password='password', charset='utf8mb4')
谁能给我解释一下:
- 什么是 local_bind_address - 是我的本地地址还是 ssh_tunnel_host 本地地址?我在哪里可以学习 IP 和端口?
- 取决于前面的问题 - 什么是 remote_bind_address - 它是 ssh_tunnel_host 还是 db_host 的地址?我在哪里可以了解这些 IP 和端口?
- 我应该在哪里连接 client.connect()?本地绑定还是远程绑定?
(我确实尝试阅读文档,但仍然一团糟)
【问题讨论】:
标签: python ssh remote-access ssh-tunnel