通过 EC2 实例之间的 SSH 隧道使用袜子代理进行 Curl 失败:“curl:(7) 无法接收 SOCKS5 连接请求确认。”

Thi*_*lle 4 ssh proxy curl amazon-ec2 socks

我在通过 AWS 中的两个 EC2 实例之间的简单 SSH 隧道设置袜子代理时遇到了卷曲问题。

box1 $ ssh -v -D 12345 ubuntu@box2 -N
[...]
Run Code Online (Sandbox Code Playgroud)

袜子代理似乎在端口 12345 上正常运行,现在当我尝试通过它进行卷曲时:

box1 $ curl -x socks5h://localhost:12345 www.google.com
curl: (7) Failed to receive SOCKS5 connect request ack.
Run Code Online (Sandbox Code Playgroud)

回到 ssh -D 窗口,当我运行curl命令时出现此错误:

debug1: Connection to port 12345 forwarding to socks port 0 requested.
debug1: channel 1: new [dynamic-tcpip]
channel 1: open failed: administratively prohibited: open failed
debug1: channel 1: free: direct-tcpip: listening port 12345 for www.google.com port 80, connect from 127.0.0.1 port 36240 to 127.0.0.1 port 12345, nchannels 2
Run Code Online (Sandbox Code Playgroud)

有人能解释一下这里发生的事情吗?

Mos*_*ari 6

也许是因为域名地址解析为IPv6,而您的socks5代理不支持它。

在这种情况下,curl --ipv4 ...将正常工作