是否可以使用 php 通过代理建立 ssh 连接?
我的php代码是
$connection = ssh2_connect('x.x.x.x');
但它在下面给出了一个错误
PHP Warning: ssh2_connect(): Unable to connect to x.x.x.x
我也无法通过命令行建立 ssh 连接。
ssh root@x.x.x.x
解决方案(失败)
然后我找到了解决方案。我创建了**~/.ssh/config**
文件并向其中添加了代理定义。
Host x.x.x.x
Hostname x.x.x.x
User root
ProxyCommand /usr/bin/corkscrew proxy.somewebsite.com 10080 %h %p
之后我能够通过命令行连接到 ssh :)
但我仍然无法连接 php 代码。我仍然得到同样的错误:(
这里的问题是该ssh2_connection
函数不使用 ssh 配置文件。有没有办法告诉函数使用它?