[erlang-questions] Systematic debugging (ssh_sample_cli)

Brian Candler B.Candler@REDACTED
Wed Aug 20 12:46:37 CEST 2008


I have been trying to get the ssh_sample_cli application to run. This is
with R11B5 from Ubuntu Hardy.

I copied the ssh_sample_cli.erl to a local directory, and it appears to
compile and start:

  1> c(ssh_sample_cli).
  ./ssh_sample_cli.erl:128: Warning: this expression would cause a 'badarith' exception at run-time
  {ok,ssh_sample_cli}
  2> crypto:start().
  ok
  3> ssh_sample_cli:listen(2222).
  {ok,<0.46.0>}
  4>

However when I try to "ssh -p 2222 localhost help" from another terminal,
the client sees the connection drop, and the erlang shell shows

  =ERROR REPORT==== 20-Aug-2008::11:01:12 ===
  ** Generic server <0.50.0> terminating
  ** Last message in was {'EXIT',<0.47.0>,{error,eacces}}
  ** When Server state == {state,server,
                                 <0.47.0>,
                                 16,
                                 [],
                                 [{<0.51.0>,#Ref<0.0.0.213>}],
                                 0,
                                 [],
                                 [],
                                 undefined}
  ** Reason for termination ==
  ** {error,eacces}

I get a similar error if I try the ssh_sshd example from
http://www.erlang.org/doc/man/ssh_sshd.html

  Eshell V5.5.5  (abort with ^G)
  1> crypto:start().
  ok
  2> ssh_sshd:listen(9999, [{system_dir, "."}]).
  {ok,<0.41.0>}
  3>
  =ERROR REPORT==== 20-Aug-2008::11:06:32 ===
  ** Generic server <0.45.0> terminating
  ** Last message in was {'EXIT',<0.42.0>,{error,enoent}}
  ** When Server state == {state,server,
                                 <0.42.0>,
                                 16,
                                 [],
                                 [{<0.46.0>,#Ref<0.0.0.94>}],
                                 0,
                                 [{system_dir,"."}],
                                 [],
                                 undefined}
  ** Reason for termination ==
  ** {error,enoent}

Now, clearly I've missed some step. The eacces/enoent suggests to me that
it's something to do with the filesystem. (*)

But my question is really this: how should I go about debugging a problem
like this in a systematic way? That is, how do I interpret the error
messages given above, or get more detail? At the moment I cannot see how to
determine which function the error occurred in, nor the filename or line
number.

If I could see which function raised this error, and/or its arguments and in
what context it was called, it would probably be very clear what the problem
was.

Thanks,

Brian.

(*) After reading the ssh_sshd documentation more carefully, I see that
system_dir is where the ssh host key is expected to be found. I have been
able to fix the problem by "ssh-keygen -t dsa -f ssh_host_dsa_key" in the
same dir to make a new ssh host key.

But I still want to learn how to isolate problems like this systematically,
rather than by guesswork. Any pointers to documentation on how to do this
would be appreciated.



More information about the erlang-questions mailing list