簡體   English   中英

使用 python 連接到遠程服務器,添加代理

[英]Connect to remote server using python, adding proxy

我正在嘗試在遠程服務器上執行命令。 當我嘗試在 paramiko 的幫助下連接到它時,它在提供paramikoProxyCommand

client.connect(
    host['hostname'], username=host['user'],
    password='xxxx@***',
    sock=paramiko.ProxyCommand(host.get('ProxyCommand ssh <proxy_server_address>:1234 nc %h %p'))
)

傳遞ProxyCommand以建立連接的正確方法是什么。

你不需要給出ProxyCommand這個詞,試試這個:

sock = paramiko.ProxyCommand("ssh {}@{} nc <proxy_server_address>:1234".format(host_cfg.get('username'), host_cfg.get('host')))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM