-
Bug
-
Resolution: Fixed
-
Major
-
None
Hi
I am trying the following code to use call home for ssh:
try (Socket socket = createSocket(getProperties().getChSshPort())) {
if (socket == null)
{ return false; }else
{ LOGGER.info("Connection received from " + socket.getInetAddress()); } connection = new Connection(socket.getInetAddress().getHostAddress(), getProperties().getChSshPort());
connection.setTCPNoDelay(true);
if (knownHostsFile.exists())
connection.connect(new NetconfKnownHostsVerifier(knownHosts, knownHostsFile), 5000000, 5000000);
auth();
session = connection.openSession();
session.startSubSystem(getProperties().getSubsystem());
} catch (IOException ioe)
{ //throw new exception. }Then when we are running we get the following error message:
2024-10-10 08:42:13,932 (Slf4jLogConsumer.java:73) INFO : STDERR: [INF]: LN: Call Home client "default-client" endpoint "default-ssh" connecting... 2024-10-10 08:42:13,932 (Slf4jLogConsumer.java:73) INFO : STDERR: [INF]: LN: Trying to connect via IPv4 to 172.17.0.3:4334. 2024-10-10 08:42:13,932 (Slf4jLogConsumer.java:73) INFO : STDERR: [INF]: LN: Successfully connected to host.testcontainers.internal:4334 over IPv4. 2024-10-10 08:42:13,932 (Slf4jLogConsumer.java:73) INFO : STDERR: [ERR]: LN: SSH key exchange error (Socket error: disconnected).
We can see that we successfully connect to the socket but then the ssh key exchanges fails. Not sure why since there is no actual message telling us.
We trigger connection from server ( using call home since it is behind a firewall) and our client that uses trilead ssh2 uses something like:
Socket createSocket(int port) { Socket socket = null; try (ServerSocket serverSocket = new ServerSocket(port)) { serverSocket.bind(new InetSocketAddress(port)); serverSocket.setSoTimeout(properties.getCallHomeConnectTimeout()); LOGGER.info("Call Home listening on port [{}]", port); socket = serverSocket.accept(); LOGGER.info("Call Home accepted connection on host '{}' [{}]", socket.getInetAddress().getHostAddress(), port); } catch (Exception e) { LOGGER.warn("Failed to create a TCP socket on port" + port, e); } return socket; }
And as seen from the error message we can connect to socket but when we try to re-use it
in trilead we cannot make the key exchange but for some unknown reason.
I don't see we cannot reuse an socket and make the ssh protocol handling on that in this library.
Why is it not working?