[erlang-questions] Replacing default shell in sshd

David Svanlund erlang-questions@REDACTED
Sun Nov 9 10:20:37 CET 2008


After some digging in shell.erl I believe that just ending the loop is  
the correct way to do it. The default shell doesn't do anything  
special, except cleanup.

David


9 nov 2008 kl. 06.30 skrev Charles Ahn:

> I've tried it out and it works! I was curious to see if the  
> io:get_line would only work in that particular spawned process and  
> so I split off the get_line to another process and it still works  
> somehow. Thanks for the help!
>
> Is there a better way of disconnecting the user than ending the loop  
> though?
>
> 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