Discussion:
libssh session connection timed out error
saeed
2014-08-22 16:54:54 UTC
Permalink
I've downloaded and compiled libssh 0.6.1 from libSSH
<http://www.libssh.org/> .
I also linked the ssh.lib,ssh.dll to a visual c++ project .
The library with code below compiles and run fine ,
but when calling ssh_connect() , it return -1 : Timeout .
I used the option :

ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);

to print the logging , and it says :

ssh_connect : socket connecting now waiting for callbacks to work.
ssh_connect : Timeout connecting to local host.

On my laptop i installed FreeSSHd <http://www.freesshd.com/> server and
connecting to it using putty works .

My code, until the error :

int _tmain(int argc, _TCHAR* argv[])
{

ssh_session my_ssh_session;
int verbosity = SSH_LOG_PROTOCOL;
int port = 22;
int rc;
char *password;
// Open session and set options
my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
// Connect to server
rc = ssh_connect(my_ssh_session);
if (rc != SSH_OK)
{
fprintf(stderr, "Error connecting to localhost: %s\n",
ssh_get_error(my_ssh_session));
ssh_free(my_ssh_session);
exit(-1);
}

This code example is copied from the A typical SSH session Exmple
<http://api.libssh.org/master/libssh_tutor_guided_tour.html> site .
--
Good Day
Saeed Hardan
Aris Adamantiadis
2014-08-25 20:14:09 UTC
Permalink
Hi,

Are you sure that there is no firewall ?
Are you sure libssh does not attempt to connect on IPv6 which is not
supported by FreeSSHd ?

I would also advise you not to use FreeSSHd on a production system as it
has a known vulnerability and no public patch:
http://www.rapid7.com/db/modules/exploit/windows/ssh/freesshd_authbypass

Regards,

Aris
Post by saeed
I've downloaded and compiled libssh 0.6.1 from libSSH
<http://www.libssh.org/> .
I also linked the ssh.lib,ssh.dll to a visual c++ project .
The library with code below compiles and run fine ,
but when calling ssh_connect() , it return -1 : Timeout .
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY,
&verbosity);
ssh_connect : socket connecting now waiting for callbacks to work.
ssh_connect : Timeout connecting to local host.
On my laptop i installed FreeSSHd <http://www.freesshd.com/> server
and connecting to it using putty works .
|int _tmain(int argc, _TCHAR* argv[])
{
ssh_session my_ssh_session;
int verbosity = SSH_LOG_PROTOCOL;
int port = 22;
int rc;
char *password;
// Open session and set options
my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
// Connect to server
rc = ssh_connect(my_ssh_session);
if (rc != SSH_OK)
{
fprintf(stderr, "Error connecting to localhost: %s\n",
ssh_get_error(my_ssh_session));
ssh_free(my_ssh_session);
exit(-1);
}
|
This code example is copied from the A typical SSH session Exmple
<http://api.libssh.org/master/libssh_tutor_guided_tour.html> site .
--
Good Day
Saeed Hardan
saeed
2014-08-26 10:38:44 UTC
Permalink
I found the problem , in host field i wrote "localhost" as the example but
it didn't work i changed to 127.0.0.1 now it works .
Also i used freesshd just to test thanks for warning .
Post by Aris Adamantiadis
Hi,
Are you sure that there is no firewall ?
Are you sure libssh does not attempt to connect on IPv6 which is not
supported by FreeSSHd ?
I would also advise you not to use FreeSSHd on a production system as it
http://www.rapid7.com/db/modules/exploit/windows/ssh/freesshd_authbypass
Regards,
Aris
Post by saeed
I've downloaded and compiled libssh 0.6.1 from libSSH
<http://www.libssh.org/> .
I also linked the ssh.lib,ssh.dll to a visual c++ project .
The library with code below compiles and run fine ,
but when calling ssh_connect() , it return -1 : Timeout .
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_connect : socket connecting now waiting for callbacks to work.
ssh_connect : Timeout connecting to local host.
On my laptop i installed FreeSSHd <http://www.freesshd.com/> server
and connecting to it using putty works .
|int _tmain(int argc, _TCHAR* argv[])
{
ssh_session my_ssh_session;
int verbosity = SSH_LOG_PROTOCOL;
int port = 22;
int rc;
char *password;
// Open session and set options
my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
// Connect to server
rc = ssh_connect(my_ssh_session);
if (rc != SSH_OK)
{
fprintf(stderr, "Error connecting to localhost: %s\n",
ssh_get_error(my_ssh_session));
ssh_free(my_ssh_session);
exit(-1);
}
|
This code example is copied from the A typical SSH session Exmple
<http://api.libssh.org/master/libssh_tutor_guided_tour.html> site .
--
Good Day
Saeed Hardan
Loading...