<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);">
Great! Thanks for reporting and testing it. I'll add this to maint and master in github.<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 17:27<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_xmsonormal0, li.x_xmsonormal0, div.x_xmsonormal0
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xxmsonormal, li.x_xxmsonormal, div.x_xxmsonormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif}
p.x_xxmsochpdefault, li.x_xxmsochpdefault, div.x_xxmsochpdefault
        {margin-right:0in;
        margin-left:0in;
        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:10.0pt;
        font-family:"Calibri",sans-serif}
span.x_xmsohyperlink
        {color:#0563C1;
        text-decoration:underline}
span.x_xmsohyperlinkfollowed
        {color:#954F72;
        text-decoration:underline}
span.x_xxmsohyperlink
        {color:#0563C1;
        text-decoration:underline}
span.x_xxmsohyperlinkfollowed
        {color:#954F72;
        text-decoration:underline}
span.x_xxemailstyle17
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_xemailstyle24
        {font-family:"Calibri",sans-serif;
        color:windowtext}
span.x_EmailStyle31
        {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">It works!</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Many 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 16:15<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">I've found it.</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">The server and client has no common mac algorithm.  I tried to add 'hmac-sha1-96' to 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">$ git diff</span></p>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">diff --git a/lib/ssh/src/ssh_transport.erl b/lib/ssh/src/ssh_transport.erl</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">index a85926354e..66d06c3360 100644</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">--- a/lib/ssh/src/ssh_transport.erl</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">+++ b/lib/ssh/src/ssh_transport.erl</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">@@ -171,6 +171,7 @@ supported_algorithms(mac) -></span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">        [{'hmac-sha2-256',    [{macs,hmac}, {hashs,sha256}]},</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">         {'hmac-sha2-512',    [{macs,hmac}, {hashs,sha512}]},</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">         {'hmac-sha1',        [{macs,hmac}, {hashs,sha}]},</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">+        {'hmac-sha1-96',     [{macs,hmac}, {hashs,sha}]},</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">         {'AEAD_AES_128_GCM', [{ciphers,aes_128_gcm}]},</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">         {'AEAD_AES_256_GCM', [{ciphers,aes_256_gcm}]}</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black">        ]</span></p>
</div>
</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">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.</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">Could you patch your Erlang client, test and tell me it it works?</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"> József Bérces <<a href="mailto:jozsef.berces@ericsson.com">jozsef.berces@ericsson.com</a>><br>
<b>Skickat:</b> den 8 oktober 2019 14:36<br>
<b>Till:</b> Hans Nilsson R <<a href="mailto:hans.r.nilsson@ericsson.com">hans.r.nilsson@ericsson.com</a>>; Erlang Questions <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>
<b>Ämne:</b> RE: ssh:connect "Key exchange failed"</span> </p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">Hi Hans,</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I tried it with several OTP releases up to 21. I have not tried OTP 22.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Here is what I received with telnet:</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">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_xmsonormal">                 es,i-default</p>
<p class="x_xmsonormal">                             es,i-defaultConnection closed by foreign host.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">And these are the default algorithms:</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">[{kex,['ecdh-sha2-nistp384','ecdh-sha2-nistp521',</p>
<p class="x_xmsonormal">       'ecdh-sha2-nistp256','diffie-hellman-group-exchange-sha256',</p>
<p class="x_xmsonormal">       'diffie-hellman-group16-sha512',</p>
<p class="x_xmsonormal">       'diffie-hellman-group18-sha512',</p>
<p class="x_xmsonormal">       'diffie-hellman-group14-sha256',</p>
<p class="x_xmsonormal">       'diffie-hellman-group14-sha1',</p>
<p class="x_xmsonormal">       'diffie-hellman-group-exchange-sha1']},</p>
<p class="x_xmsonormal">{public_key,['ecdsa-sha2-nistp384','ecdsa-sha2-nistp521',</p>
<p class="x_xmsonormal">              'ecdsa-sha2-nistp256','ssh-rsa','rsa-sha2-256',</p>
<p class="x_xmsonormal">              'rsa-sha2-512','ssh-dss']},</p>
<p class="x_xmsonormal">{cipher,[{client2server,['aes256-gcm@openssh.com',</p>
<p class="x_xmsonormal">                          'aes256-ctr','aes192-ctr','aes128-gcm@openssh.com',</p>
<p class="x_xmsonormal">                          'aes128-ctr','aes128-cbc','3des-cbc']},</p>
<p class="x_xmsonormal">          {server2client,['aes256-gcm@openssh.com','aes256-ctr',</p>
<p class="x_xmsonormal">                          'aes192-ctr','aes128-gcm@openssh.com','aes128-ctr',</p>
<p class="x_xmsonormal">                          'aes128-cbc','3des-cbc']}]},</p>
<p class="x_xmsonormal">{mac,[{client2server,['hmac-sha2-256','hmac-sha2-512',</p>
<p class="x_xmsonormal">                       'hmac-sha1']},</p>
<p class="x_xmsonormal">       {server2client,['hmac-sha2-256','hmac-sha2-512',</p>
<p class="x_xmsonormal">                       'hmac-sha1']}]},</p>
<p class="x_xmsonormal">{compression,[{client2server,[none,'zlib@openssh.com',zlib]},</p>
<p class="x_xmsonormal">               {server2client,[none,'zlib@openssh.com',zlib]}]}]</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">5> ssh_transport:supported_algorithms(mac).</p>
<p class="x_xmsonormal">[{client2server,['hmac-sha2-256','hmac-sha2-512',</p>
<p class="x_xmsonormal">                 'hmac-sha1','AEAD_AES_128_GCM','AEAD_AES_256_GCM']},</p>
<p class="x_xmsonormal">{server2client,['hmac-sha2-256','hmac-sha2-512','hmac-sha1',</p>
<p class="x_xmsonormal">                 'AEAD_AES_128_GCM','AEAD_AES_256_GCM']}]</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Thanks,</p>
<p class="x_xmsonormal">Jozsef</p>
<p class="x_xmsonormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_xmsonormal"><b>From:</b> Hans Nilsson R <<a href="mailto:hans.r.nilsson@ericsson.com">hans.r.nilsson@ericsson.com</a>>
<br>
<b>Sent:</b> Tuesday, 8 October, 2019 10:47<br>
<b>To:</b> József Bérces <<a href="mailto:jozsef.berces@ericsson.com">jozsef.berces@ericsson.com</a>>; Erlang Questions <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>
<b>Subject:</b> Sv: ssh:connect "Key exchange failed"</p>
</div>
</div>
<p class="x_xmsonormal"> </p>
<div>
<p class="x_xmsonormal"><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_xmsonormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
</div>
<div>
<p class="x_xmsonormal"><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_xmsonormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
</div>
<div>
<p class="x_xmsonormal"><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_xmsonormal"><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_xmsonormal"><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_xmsonormal"><span style="font-size:10.0pt; font-family:"Courier New"; color:black"> </span></p>
</div>
<div>
<p class="x_xmsonormal"><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_x_divRplyFwdMsg">
<p class="x_xmsonormal"><b><span style="color:black">Frċn:</span></b><span style="color:black">
<a href="mailto:erlang-questions-bounces@erlang.org">erlang-questions-bounces@erlang.org</a> <<a href="mailto:erlang-questions-bounces@erlang.org">erlang-questions-bounces@erlang.org</a>> för József Bérces <<a href="mailto:jozsef.berces@ericsson.com">jozsef.berces@ericsson.com</a>><br>
<b>Skickat:</b> den 8 oktober 2019 09:23<br>
<b>Till:</b> Erlang Questions <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>><br>
<b>Ämne:</b> [erlang-questions] ssh:connect "Key exchange failed"</span> </p>
<div>
<p class="x_xmsonormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xxmsonormal">Hi,</p>
<p class="x_xxmsonormal"> </p>
<p class="x_xxmsonormal">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_xxmsonormal"> </p>
<p class="x_xxmsonormal">Could you please check the KiTTY log below what is not supported by the Erlang SSH client?
</p>
<p class="x_xxmsonormal"> </p>
<p class="x_xxmsonormal">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_xxmsonormal"> </p>
<p class="x_xxmsonormal">Thanks,</p>
<p class="x_xxmsonormal">Jozsef</p>
<p class="x_xxmsonormal"> </p>
<p class="x_xxmsonormal">2019-10-07 14:37:58       Starting 42264 from XXXXX@XXXXXX</p>
<p class="x_xxmsonormal">2019-10-07 14:38:07       Connecting to 10.XXX.XXX.XXX port 22</p>
<p class="x_xxmsonormal">2019-10-07 14:38:07       We claim version: SSH-2.0-PuTTY_KiTTY</p>
<p class="x_xxmsonormal">2019-10-07 14:38:07       Server version: SSH-2.0-Sun_SSH_1.1.5</p>
<p class="x_xxmsonormal">2019-10-07 14:38:07       Using SSH protocol version 2</p>
<p class="x_xxmsonormal">2019-10-07 14:38:08       Doing Diffie-Hellman group exchange</p>
<p class="x_xxmsonormal">2019-10-07 14:38:08       Doing Diffie-Hellman key exchange with hash SHA-1</p>
<p class="x_xxmsonormal">2019-10-07 14:38:08       Server also has ssh-dss host key, but we don't know it</p>
<p class="x_xxmsonormal">2019-10-07 14:38:08       Host key fingerprint is:</p>
<p class="x_xxmsonormal">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_xxmsonormal">2019-10-07 14:38:16       Initialised AES-256 CBC client->server encryption</p>
<p class="x_xxmsonormal">2019-10-07 14:38:16       Initialised HMAC-SHA1-96 client->server MAC algorithm</p>
<p class="x_xxmsonormal">2019-10-07 14:38:16       Initialised AES-256 CBC server->client encryption</p>
<p class="x_xxmsonormal">2019-10-07 14:38:16       Initialised HMAC-SHA1-96 server->client MAC algorithm</p>
<p class="x_xxmsonormal">2019-10-07 14:38:22       Using SSPI from SECUR32.DLL</p>
<p class="x_xxmsonormal">2019-10-07 14:38:22       Attempting GSSAPI authentication</p>
<p class="x_xxmsonormal">2019-10-07 14:38:22       GSSAPI authentication initialisation failed</p>
<p class="x_xxmsonormal">2019-10-07 14:38:22       The target was not recognized.</p>
<p class="x_xxmsonormal">2019-10-07 14:38:22       Attempting keyboard-interactive authentication</p>
<p class="x_xxmsonormal">2019-10-07 14:38:30       Access granted</p>
<p class="x_xxmsonormal">2019-10-07 14:38:30       Opening session as main channel</p>
<p class="x_xxmsonormal">2019-10-07 14:38:30       Opened main channel</p>
<p class="x_xxmsonormal">2019-10-07 14:38:30       Allocated pty (ospeed 38400bps, ispeed 38400bps)</p>
<p class="x_xxmsonormal">2019-10-07 14:38:31       Started a shell/command</p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>