Код: Выделить всё
ssh_tunnel_server = {
'ssh_address_or_host': (remote_host, 22),
'ssh_username': ssh_user,
'ssh_pkey': ssh_key_path,
'remote_bind_address': ("localhost", 5900),
'local_bind_address': ('127.0.0.1', 0),
}
tunnel = SSHTunnelForwarder(**ssh_tunnel_server)
tunnel.start()
Используя напрямую paramiko, я обнаружил, что простое ssh-соединение с центрами сертификации может установить просто путем предоставления открытого ключа центра сертификации в качестве параметра key_filename. С помощью open_session() я также мог выполнять команды.
Код: Выделить всё
client.connect(ssh_host, port=ssh_port, username=ssh_user, pkey=private_key, key_filename=ssh_cert_path)
Код: Выделить всё
transport.request_port_forward("localhost", local_port,handler(channel, "127.0.0.1",remote_port))
Код:
Код: Выделить всё
def forward_tunnel(local_port, remote_host, remote_port, transport: Transport):
transport.request_port_forward("", local_port)
while True:
chan = transport.accept(1000)
if chan is None:
continue
thr = threading.Thread(target=handler, args=(chan, remote_host, remote_port))
thr.setDaemon(True)
thr.start()
Подробнее здесь: https://stackoverflow.com/questions/791 ... ith-ca-key