这是我非常简单的代码,旨在通过端口8888上的本地socks代理连接到ssh服务器
import subprocess
host = 'X.x.X.x'
port = 22
subprocess.call( [
"ssh",
"-o", "ProxyCommand='/bin/socat - SOCKS4A:127.0.0.1:%h:%p,socksport=8888'",
"-p", "{}".format(port),
"root@{}".format(host)
])
但是,在尝试执行时,我收到了一条难看的错误消息。
/bin/bash: /bin/socat - SOCKS4A:127.0.0.1:X.x.X.x:22,socksport=8888: No such file or directory
ssh_exchange_identification: Connection closed by remote host
什么是trange,当直接将完整的命令行复制粘贴到外壳上时,这是可行的。