<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
I've found it.</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
The server and client has no common mac algorithm.  I tried to add 'hmac-sha1-96' to Erlang SSH:</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<span>$ git diff<br>
</span>
<div>diff --git a/lib/ssh/src/ssh_transport.erl b/lib/ssh/src/ssh_transport.erl<br>
</div>
<div>index a85926354e..66d06c3360 100644<br>
</div>
<div>--- a/lib/ssh/src/ssh_transport.erl<br>
</div>
<div>+++ b/lib/ssh/src/ssh_transport.erl<br>
</div>
<div>@@ -171,6 +171,7 @@ supported_algorithms(mac) -><br>
</div>
<div>        [{'hmac-sha2-256',    [{macs,hmac}, {hashs,sha256}]},<br>
</div>
<div>         {'hmac-sha2-512',    [{macs,hmac}, {hashs,sha512}]},<br>
</div>
<div>         {'hmac-sha1',        [{macs,hmac}, {hashs,sha}]},<br>
</div>
<div>+        {'hmac-sha1-96',     [{macs,hmac}, {hashs,sha}]},<br>
</div>
<div>         {'AEAD_AES_128_GCM', [{ciphers,aes_128_gcm}]},<br>
</div>
<div>         {'AEAD_AES_256_GCM', [{ciphers,aes_256_gcm}]}<br>
</div>
<div>        ]<br>
</div>
<span></span></div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
I can't test it because I have no ssh server at hand that has that old mac. But it works with erlang client to erlang server.</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
Could you patch your Erlang client, test and tell me it it works?</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
/Hans<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Från:</b> József Bérces <jozsef.berces@ericsson.com><br>
<b>Skickat:</b> den 8 oktober 2019 14:36<br>
<b>Till:</b> Hans Nilsson R <hans.r.nilsson@ericsson.com>; Erlang Questions <erlang-questions@erlang.org><br>
<b>Ämne:</b> RE: ssh:connect "Key exchange failed"</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
        {color:#0563C1;
        text-decoration:underline}
a:visited, span.x_MsoHyperlinkFollowed
        {color:#954F72;
        text-decoration:underline}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xmsochpdefault, li.x_xmsochpdefault, div.x_xmsochpdefault
        {margin-right:0in;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
span.x_xmsohyperlink
        {color:#0563C1;
        text-decoration:underline}
span.x_xmsohyperlinkfollowed
        {color:#954F72;
        text-decoration:underline}
span.x_xemailstyle17
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_EmailStyle24
        {font-family:"Calibri",sans-serif;
        color:windowtext}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi Hans,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">I tried it with several OTP releases up to 21. I have not tried OTP 22.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Here is what I received with telnet:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">QþCb8é¢ê˜x|qâob‚gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1ssh-rsa,ssh-dss aes256-cbc,aes192-cbc,aes128-cbc aes256-cbc,aes192-cbc,aes128-cbchmac-sha1-96,hmac-md5-96hmac-sha1-96,hmac-md5-96    
 none,zlib       none,zlib</p>
<p class="x_MsoNormal">                 es,i-default</p>
<p class="x_MsoNormal">                             es,i-defaultConnection closed by foreign host.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">And these are the default algorithms:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">[{kex,['ecdh-sha2-nistp384','ecdh-sha2-nistp521',</p>
<p class="x_MsoNormal">       'ecdh-sha2-nistp256','diffie-hellman-group-exchange-sha256',</p>
<p class="x_MsoNormal">       'diffie-hellman-group16-sha512',</p>
<p class="x_MsoNormal">       'diffie-hellman-group18-sha512',</p>
<p class="x_MsoNormal">       'diffie-hellman-group14-sha256',</p>
<p class="x_MsoNormal">       'diffie-hellman-group14-sha1',</p>
<p class="x_MsoNormal">       'diffie-hellman-group-exchange-sha1']},</p>
<p class="x_MsoNormal">{public_key,['ecdsa-sha2-nistp384','ecdsa-sha2-nistp521',</p>
<p class="x_MsoNormal">              'ecdsa-sha2-nistp256','ssh-rsa','rsa-sha2-256',</p>
<p class="x_MsoNormal">              'rsa-sha2-512','ssh-dss']},</p>
<p class="x_MsoNormal">{cipher,[{client2server,['aes256-gcm@openssh.com',</p>
<p class="x_MsoNormal">                          'aes256-ctr','aes192-ctr','aes128-gcm@openssh.com',</p>
<p class="x_MsoNormal">                          'aes128-ctr','aes128-cbc','3des-cbc']},</p>
<p class="x_MsoNormal">          {server2client,['aes256-gcm@openssh.com','aes256-ctr',</p>
<p class="x_MsoNormal">                          'aes192-ctr','aes128-gcm@openssh.com','aes128-ctr',</p>
<p class="x_MsoNormal">                          'aes128-cbc','3des-cbc']}]},</p>
<p class="x_MsoNormal">{mac,[{client2server,['hmac-sha2-256','hmac-sha2-512',</p>
<p class="x_MsoNormal">                       'hmac-sha1']},</p>
<p class="x_MsoNormal">       {server2client,['hmac-sha2-256','hmac-sha2-512',</p>
<p class="x_MsoNormal">                       'hmac-sha1']}]},</p>
<p class="x_MsoNormal">{compression,[{client2server,[none,'zlib@openssh.com',zlib]},</p>
<p class="x_MsoNormal">               {server2client,[none,'zlib@openssh.com',zlib]}]}]</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">5> ssh_transport:supported_algorithms(mac).</p>
<p class="x_MsoNormal">[{client2server,['hmac-sha2-256','hmac-sha2-512',</p>
<p class="x_MsoNormal">                 'hmac-sha1','AEAD_AES_128_GCM','AEAD_AES_256_GCM']},</p>
<p class="x_MsoNormal">{server2client,['hmac-sha2-256','hmac-sha2-512','hmac-sha1',</p>
<p class="x_MsoNormal">                 'AEAD_AES_128_GCM','AEAD_AES_256_GCM']}]</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Thanks,</p>
<p class="x_MsoNormal">Jozsef</p>
<p class="x_MsoNormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b>From:</b> Hans Nilsson R <hans.r.nilsson@ericsson.com> <br>
<b>Sent:</b> Tuesday, 8 October, 2019 10:47<br>
<b>To:</b> József Bérces <jozsef.berces@ericsson.com>; Erlang Questions <erlang-questions@erlang.org><br>
<b>Subject:</b> Sv: ssh:connect "Key exchange failed"</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">The "Key exchange failed" error indicates that there is no agreement in the first phase where different algorithms are negotiated.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">A common cause is that there are no common cipher algorithm available. For example the AES-256 CBC is not available in Erlang SSH.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">Which otp version do you use?</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">What does the function ssh:default_algorithms() return?</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">What algorithms does the server provide?  (Check by telnet the server, type "SSH-2.0-xxx" and look at the funny characters that is returned. Or post them here)</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">/Hans
</span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">Från:</span></b><span style="color:black"> erlang-questions-bounces@erlang.org <erlang-questions-bounces@erlang.org> för József Bérces <jozsef.berces@ericsson.com><br>
<b>Skickat:</b> den 8 oktober 2019 09:23<br>
<b>Till:</b> Erlang Questions <erlang-questions@erlang.org><br>
<b>Ämne:</b> [erlang-questions] ssh:connect "Key exchange failed"</span> </p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">Hi,</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I need to connect to an ssh server but ssh:connect always returns "Key exchange failed". I can connect with KiTTY, and checking the KiTTY logs I suspect that the problem is the 1024-bit RSA key.
</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Could you please check the KiTTY log below what is not supported by the Erlang SSH client?
</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Is there any way to add the missing support to the Erlang SSH client so that I could connect to this server?</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Thanks,</p>
<p class="x_xmsonormal">Jozsef</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">2019-10-07 14:37:58       Starting 42264 from XXXXX@XXXXXX</p>
<p class="x_xmsonormal">2019-10-07 14:38:07       Connecting to 10.XXX.XXX.XXX port 22</p>
<p class="x_xmsonormal">2019-10-07 14:38:07       We claim version: SSH-2.0-PuTTY_KiTTY</p>
<p class="x_xmsonormal">2019-10-07 14:38:07       Server version: SSH-2.0-Sun_SSH_1.1.5</p>
<p class="x_xmsonormal">2019-10-07 14:38:07       Using SSH protocol version 2</p>
<p class="x_xmsonormal">2019-10-07 14:38:08       Doing Diffie-Hellman group exchange</p>
<p class="x_xmsonormal">2019-10-07 14:38:08       Doing Diffie-Hellman key exchange with hash SHA-1</p>
<p class="x_xmsonormal">2019-10-07 14:38:08       Server also has ssh-dss host key, but we don't know it</p>
<p class="x_xmsonormal">2019-10-07 14:38:08       Host key fingerprint is:</p>
<p class="x_xmsonormal">2019-10-07 14:38:08       ssh-rsa 1024 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX</p>
<p class="x_xmsonormal">2019-10-07 14:38:16       Initialised AES-256 CBC client->server encryption</p>
<p class="x_xmsonormal">2019-10-07 14:38:16       Initialised HMAC-SHA1-96 client->server MAC algorithm</p>
<p class="x_xmsonormal">2019-10-07 14:38:16       Initialised AES-256 CBC server->client encryption</p>
<p class="x_xmsonormal">2019-10-07 14:38:16       Initialised HMAC-SHA1-96 server->client MAC algorithm</p>
<p class="x_xmsonormal">2019-10-07 14:38:22       Using SSPI from SECUR32.DLL</p>
<p class="x_xmsonormal">2019-10-07 14:38:22       Attempting GSSAPI authentication</p>
<p class="x_xmsonormal">2019-10-07 14:38:22       GSSAPI authentication initialisation failed</p>
<p class="x_xmsonormal">2019-10-07 14:38:22       The target was not recognized.</p>
<p class="x_xmsonormal">2019-10-07 14:38:22       Attempting keyboard-interactive authentication</p>
<p class="x_xmsonormal">2019-10-07 14:38:30       Access granted</p>
<p class="x_xmsonormal">2019-10-07 14:38:30       Opening session as main channel</p>
<p class="x_xmsonormal">2019-10-07 14:38:30       Opened main channel</p>
<p class="x_xmsonormal">2019-10-07 14:38:30       Allocated pty (ospeed 38400bps, ispeed 38400bps)</p>
<p class="x_xmsonormal">2019-10-07 14:38:31       Started a shell/command</p>
</div>
</div>
</div>
</div>
</body>
</html>