0

Have a docker container build using php-ssh2. php version 7.2 When trying to use

$con = ssh2_connect('hostname');

I am getting Error starting up SSH connection(-43): Failed getting banner . Interesting thing is 43 here. Whats the significance of 43. What does that mean? Also any idea how to fix this? There is no heavy load, running connection manually.

Kingshuk Deb
  • 1,700
  • 2
  • 26
  • 40

1 Answers1

3

Deepdive into libssh2

This number -43 is an error code that comes directly from libssh2, specifically LIBSSH2_ERROR_SOCKET_RECV. The Failed getting banner message is the dynamic error message that accompanies the error code. These two pieces of information give the location where this error is thrown, namely in the receive_banner.

Underlying problem

It was the result of the socket throwing a receive error when libssh2 tried to read from it as part of initialising your SSH session. Either the server is misconfigured and is not sending a banner or the underlying connection disconnected for some reason.

Solution

The best course of action seems to have adequate retrying in place for these kinds of errors. You are connecting to a network which is an action that can fail. As the number of servers you are connecting to increases, you are going to run into errors that are a result of the underlying network. Adequate error handling is your best course of action.

You can find how to set exception handlers from the PHP docs.

Reinier Maas
  • 31
  • 1
  • 3