【发布时间】:2014-03-31 15:39:13
【问题描述】:
我想使用代理/socks throw ssh 服务器,我从这里How do you proxy though a server using ssh (socks…) using php’s CURL? 找到了很好的示例,但是示例不起作用,这是我的代码。
<?php
$connection = ssh2_connect("64.246.126.25", 22);
if(ssh2_auth_password($connection, "ubnt", "ubnt"))
{
if ($tunnel = ssh2_tunnel($connection, "127.0.0.1", 9999))
{
$url = "http://checkip.dyndns.com/";
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:9999");
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
$result = curl_exec($ch);
echo $result;
}else{
echo "Tunnel creation failed.\n";
}
}
else
{
echo "failed!";
}
?>
当我执行这个脚本时,我有错误响应:
Warning: ssh2_tunnel() [function.ssh2-tunnel]: Unable to request a channel from remote host in /home/domain.com/ssh2/index.php on line 7
Tunnel creation failed.
我会搜索这个错误并尝试修复但无法解决问题。
谁能帮帮我?
【问题讨论】: