问题描述
我正在使用Python编写一些自动服务器连接脚本。 要访问某些服务器,我需要代理SSH连接。 我有以下错误使我认为这与 ProxyCommand 值的处理有关:
/ bin / bash:/ usr / bin / ncat --proxy 127.0.0.1:9000 --proxy-type袜子5 10.230.10.5 22:没有这样的文件或目录
相关的python代码为:
cmd = ['ssh','-t','-N','-f','-o',"ProxyCommand='/usr/bin/ncat --proxy 127.0.0.1:9000 --proxy-type socks5 %h %p'",'ExitOnForwardFailure=yes','-p','22','root@10.230.10.5']
ret = subprocess.call(cmd)
但是,当直接在服务器上键入这样的命令时,它可以正常工作:
ssh -t -t -N -f -o ProxyCommand='/usr/bin/ncat --proxy 127.0.0.1:9000 --proxy-type socks5 %h %p' -o ExitOnForwardFailure=yes -p 22 root@10.230.10.5
您对如何处理ProxyCommand值有一个想法,以便 bash 理解吗?
感谢您的帮助
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)