J-Rios / Arduino-esp32sshclient

Arduino library for ESP32 that implements an SSH client to connect and execute commands in a remote Server.
GNU General Public License v3.0
45 stars 13 forks source link

Fall into infinite loop (SSH Session handshake fail) #1

Closed HelloDB closed 5 years ago

HelloDB commented 5 years ago

Hi! Thanks for library. Test example falls into an infinite loop

esp32sshclient.cpp:291

while(rc == LIBSSH2_ERROR_EAGAIN)
{
// Some delay here could be nice
rc = libssh2_session_handshake(session, sock);
}
J-Rios commented 5 years ago

Added timeouts for unhandled loops, now it should exit loops.

I test all working examples with an OpenSSH Server: OpenSSH_6.7p1 Debian-5+deb8u8, OpenSSL 1.0.1t 3 May 2016

HelloDB commented 5 years ago

Thanks for your reply The test still failed. Failure establishing SSH session: -125 My server: CentOS Linux release 7.2.1511 (Core) OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 Testing SSH on CMD is normal

J-Rios commented 5 years ago

Error code -125 is for timeout, so now there is no infinite loop and fix was successfully working ok.

So your problem is that session handshake with server can't be completed for some unknown reason. Note that this is just a proof of concept library provided as is without warranty of works in all situations or configurations, I test that is working ok with OpenSSH 6.7 and OpenSSL 1.0.1t, so your problem could be related to OpenSSH version or any specific configuration. Maybe you can get some info of what is going on checking OpenSSH log file in the server...

HelloDB commented 5 years ago

I saw sshd[15049]: error: kex protocol error: type 30 seq 1 [preauth] in the log but I have given up the test, thank you still

J-Rios commented 5 years ago

This library is built on top of libssh2 library, I just take a look into libssh2 repository and 10 days ago was released a new version (1.9.0) so I have just updated to this version in the library. Maybe you can try again now to check if some changelog of libssh2 was related with your issue...

Also: https://github.com/Studio3T/robomongo/issues/1423

HelloDB commented 5 years ago

Successful ,I almost missed! :smile:

solution: https://github.com/Studio3T/robomongo/issues/1125