[英]Connect to remote server using python, adding proxy
I am trying to execute a command on a remote server.我正在尝试在远程服务器上执行命令。 When I try to connect to it with the help of paramiko
, it fails while giving the ProxyCommand
当我尝试在 paramiko 的帮助下连接到它时,它在提供paramiko
时ProxyCommand
client.connect(
host['hostname'], username=host['user'],
password='xxxx@***',
sock=paramiko.ProxyCommand(host.get('ProxyCommand ssh <proxy_server_address>:1234 nc %h %p'))
)
What is the correct approach to pass the ProxyCommand
, for establishing the connection.传递ProxyCommand
以建立连接的正确方法是什么。
you do not need to give the word ProxyCommand
, try this:你不需要给出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.