0

I am using an SSH tunnel to establish an SSH connection to a device, I am creating the tunnel with:

ssh -L localhost:44445:X.X.X.X:XXXX [email protected]

However when I try to ssh through the tunnel with:

ssh root@localhost:44445 
Unable to negotiate with 127.0.0.1 port 44445: no matching key exchange method found. Their offer: diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

However, if I move the same machine into the same network where my device is and I try to connect directly to the device - hence without using the SSH tunnel -connection is successful.

I can connect using the following option when running the SSH client through the tunnel, however I need to be able to connect without that.

-o KexAlgorithms=+diffie-hellman-group14-sha1

Funny enough I can connect using the ProxyJump option - that works fine however it is not what I want as I need to use a tunnel to be used by a 3rd party app.

ssh -J [email protected] [email protected]

2 Answers 2

0

Your other machine most likely has either an older version of the OpenSSH client that didn't yet refuse to use the old DH algorithms by default (the list of "acceptable" algorithms has changed over time), or a different SSH client entirely (e.g. PuTTY is much less strict in that regard).

If you merely need to connect without modifications to the command, then you can add the same SSH options to your ~/.ssh/config. In fact, you can even define the whole tunnel there:

  1. ~/.ssh/config
    Host mydevice JumpHost mytunnel HostName yyyy Port zzz KexAlgorithms +diffie-hellman-group14-sha1 Host mytunnel HostName x.x.x.x User root
  2. $ ssh mydevice

If that's not an option, use a different SSH client, such as PuTTY:

  • $ plink root@localhost -P 44445

And if you need to connect without any modifications to the SSH client, the only realistic option is to upgrade the SSH server so that it supports newer algorithms.

3
  • When you refer to the other machine I reckon you meant the machine where the tunnel has been setup on, please correct me if I am wrong, I thought that the tunnel would wrap and unwrap the contents - which in this case it happens to be SSH payload - hence the tunnel would not make any difference in the communications among the SSH client and the SSH server on the device. Is there a manual or something that helps me in making sense of this ? Commented Mar 21 at 14:24
  • I'm referring to "However, if I try to access from a different machine which sits in the same network as the device and try to connect [...] connection is successful". As you said yourself, the fact that the 'different machine' isn't using a tunnel is very unlikely to be related to the problem – more likely it's just that it has a different version of the SSH client than the 'tunnel' machine. Commented Mar 21 at 14:28
  • Sorry, my bad, it is the same machine using exactly the same ssh client Commented Mar 21 at 15:51
0

I agree with @u1686_grawity: but maybe the problem is related to the SSH established with the tunnel machine and not with the final device. Rewriteing a bit your command

ssh -L localhost:44445:<finalDeviceIP>:<port> root@<tunnelMachineIP>

You said

if I move the same machine into the same network where my device is and I try to connect directly to the device - hence without using the SSH tunnel -connection is successful

hence, the ssh connection to <finalDeviceIP> works fine. However, when you goes by <tunnelMachineIP> you get the error since (probably) that machine has a too old ssh version.
In the tunnel connection indeed, the first ssh session is established with <tunnelMachineIP>, which then, as you said, wrap and unwrap the payload for the second ssh session you want to esatblish with <finalDeviceIP>.
As @u1686_grawity suggested, you should update the ssh server onboard the <tunnelMachineIP>. Or you can setup the tunnel inside the ssh config file of your client (even if probably you should move the option KexAlgorithms +diffie-hellman-group14-sha1 under the Host mytunnel section).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .