[erlang-questions] Replacing default shell in sshd

Charles Ahn nexes300@REDACTED
Sun Nov 9 10:59:53 CET 2008


Hello,

I've noticed that when I end a connection by breaking out of the loop,  
all connections also get terminated (regardless of login). How do I  
prevent this from happening? Also, is there a way to tell the shell  
which user it is representing? Here's my loop code:
loop(Rec) ->
   receive
     {Rec, Line} ->
       NewLine = <<?FGGREEN/binary, Line/binary>>,
       io:format("~s",[NewLine])
   end,
   case Line of
     <<"quit\n">> -> io:format("Good bye!\n");
     _ -> loop(Rec)
   end.

Thanks again for the help so far.

Charles

On Nov 8, 2008, at 2:19 AM, David Svanlund wrote:

> Charles,
>
> I experimented with the ssh module a couple of days ago. The
> (incomplete) example code below might help you understand how to
> replace the default shell.
>
> -module(ssh_example).
> -export([start/0, dispatch/0, hello/0]).
>
> start() ->
>   ssh:daemon({0,0,0,0}, 1122, [{shell, {?MODULE, dispatch, []}},
> {user_passwords, [{"davidsvanlund", "banana"}]}]).
>
> dispatch() ->
>   spawn(?MODULE, hello, []).
>
> hello() ->
>   io:format("Hello user!\n"),
>   loop().
>
> loop() ->
>   Line = io:get_line("> "),
>   io:format(Line),
>   loop().
>
>
> David
>
>
> 8 nov 2008 kl. 05.39 skrev Charles Ahn:
>
>> I was looking at the ssh module because I was somewhat interested in
>> making a MUD in erlang that people can ssh into, but I can't quite
>> figure out how I should go about doing this.
>>
>> It appears that {shell, start, []} is the default shell, but when I
>> read the related source it had a lot of code dealing with shell
>> specific code, and I could not easily figure out exactly what
>> messages the ssh module expects it to respond to. Can anyone tell me
>> exactly what kind of behavior a replacement module requires for the
>> ssh module to work correctly?
>>
>> Furthermore, does anyone see anything that makes the ssh module
>> unsuitable for what I'd like to do?
>>
>> Also, just to point something out, when I start the ssh server, the
>> server will crash if I do not have DSA keys in the system directory.
>> Having RSA keys only does not work and, in fact, I am not certain
>> the daemon is capable of using RSA keys server side.
>>
>> Charles_______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list