Cannot get phpseclib to connect - error 10060

爷,独闯天下 提交于 2019-12-11 11:35:31

问题


I cannot get my local environment, Win7 running easyPHP 12, to connect to my server, ubuntu 11.04.

I connect to my server via sftp with filezilla fine, i can connect to my server via ssh with putty fine... the server requires no keys at the moment just a uname and pword...

I don't get it, the details i am passing via the php script are exactly the same as the ones i pass from filezilla and putty.

This is the code stripped to the bare basic:

//inlcude the phpseclib path in the include array and include the ssh2 class
set_include_path( WEBROOT_PRIVATE.'scripts/phpseclib0.3.0' );
if(!include('Net/SSH2.php')){
    echo 'Sorry failed to load SSH2 class';
    br();
}
if(!include('Net/SFTP.php')){
    echo 'Sorry failed to load SFTP class';
    br();
}
$connection = new Net_SFTP( 'xx.xx.xx.xx', 'xx' );
echo 'ss';
$login = $connection->login( 'username', 'password');
exit();

And this is the response i am getting:

Notice: Cannot connect to xx.xx.xx.xx. Error 10060. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in ....\www_private\scripts\phpseclib0.3.0\Net\SSH2.php on line 776 ss


回答1:


Most likely server requires keyboard-interactive auth, while component tries password auth.




回答2:


It's failing with fsockopen with the error that you're getting, which suggests to me it's not a phpseclib problem so much as a PHP one.

So the way SSH works is that the server sends a banner immediately to you when you try to connect. It does that for stackoverflow.com for example:

<?php
$fsock = fsockopen('www.stackoverflow.com', 22);
echo fgets($fsock, 1024);

When I run that script I get "SSH-2.0-OpenSSH_5.3" back.

My guess would be that if you update that PHP script to work with your server you'll get the same error message phpseclib is giving you.



来源:https://stackoverflow.com/questions/14326406/cannot-get-phpseclib-to-connect-error-10060

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!