[erlang-bugs] ssh-2.0 "Key exchange failed" if known_hosts cannot be written

Tuncer Ayaz tuncer.ayaz@REDACTED
Thu Sep 2 23:26:48 CEST 2010


On Thu, Sep 2, 2010 at 9:31 PM, Daniel Goertzen wrote:
> While trying to use ssh:connect(), I get {error, "Key exchange failed"}.
>
> Tracing shows that it is trying to write to the file
> "c:/Users/myname/.ssh/known_hosts".  The ".ssh" dir is not present, so the
> write fails.  The error propagates up causing verify_host_key() to return
> failure which kills the connection.  The host key verified properly; it just
> couldn't be written to known_hosts.  I think it should return 'ok' in this
> case and allow the connection to proceed.
>
> My whole connect call was....
>
>  {ok,Connection} = ssh:connect(Host, Port, [
>    {user,Login},
>    {password,Pass},
>    {silently_accept_hosts, true},
>    {user_interaction, false}]),
>
> This is for a machine to machine connection, and I don't care about host key
> checking anyway.  To work around this for now, I am supplying a 'user_dir'
> option so it can write a known_hosts file.

I've sent a patch for review to erlang-patches@ which makes sure that
~/.ssh exists before trying to open any files for read/write.


More information about the erlang-bugs mailing list