[erlang-questions] Replacing default shell in sshd

Charles Ahn <>
Tue Nov 11 11:31:34 CET 2008


Hello,

Actually that was very helpful because, after reading both you and  
some documentation mention this "example" directory, I decided to  
seriously look for it, and finally found it in the source (I was  
looking in the /usr/local/lib/erlang directories before). The example  
was actually helpful because I saw it pass a 2 arity fun to  
ssh_cli:listen, and I thought I'd look for something similar in the  
actual ssh code. After some digging around (and guessing what  
supervisors did) I found start_shell in ssh_cli.erl which made it  
clear that the shell option didn't have to be a tuple of {module,  
function, args} but could instead be a function, and that answered a  
question of how to tell the custom shell which user is logged in. It's  
a shame though, if the documentation specified what kind of values the  
shell option took then it would have been a lot simpler/clearer.  
Because I thought the shell option had to be of the form {module,  
function, [args]}, I saw no way to pass User info into it, but now I  
see that it is indeed easily possible by passing {shell, fun(U)  
customShell(U) end} as an option.

I did know that there were API changes (it was why I updated to the  
newest version so I don't write a bunch of code that isn't supported  
later, heh) but I wasn't aware that it wasn't finished. Now that I  
have figured out how get the user name, I guess my only real problem  
with using ssh this way is that one user logging out seems to close  
all other connections as well. Other than that, it seems like this  
will work pretty well to make a mud, and I was rather impressed by the  
flexibility of the code (once I figured out how to make it do these  
flexible things) and the real problem for me was a lack of  
documentation.

I do have one more question, if I use io:get_line and (before the user  
inputs anything) decide I no longer want to get anything, is there a  
way to cancel the get_line?

Other than that, thanks for pointing me to that file!

Charles

On Nov 11, 2008, at 1:24 AM, Ingela Anderton Andin wrote:

> Hi!
>
>> 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?
>
> I am afraid the ssh code is not very clean at the moment. It
> has been subject to major refactoring leading up to ssh-1.0 version.  
> Alas
> due to other things getting higher priority the work with this was not
> really completed and we where forced to make a somewhat "in between  
> version"
> as there where changes needed by customers that could not wait but  
> no time to
> finish it properly. (Still called it 1.0 to reflect that it was a  
> major change and the
> API changed a lot). There are also a lot of code that is there to  
> make it work
> at least as well as before but can be really ugly and  confusing and
> in some cases even wrong, so to speak bug compatible with the older  
> version.
> And of course a lot of code is there to still support the  old API  
> to make the transistion
> smoother. Unfotunatly the old API had almost no documentation and  
> was not written
> by the OTP-team, so as far as we know latest ssh is backwards  
> compatible.
>
> I do not have a good short answer for you at the moment. There is an  
> example
> in ssh/exampels directory of a cli but I can not *guarantee *that It  
> works or is
> up to date. Maybe it can help a little.
>
> We are continuously working to improve the ssh application and as  
> usual there
> are also other things competing for our time so please have some  
> patiences, it is
> getting there.
>
>> Furthermore, does anyone see anything that makes the ssh module
>> unsuitable for what I'd like to do?
>
> Conceptually I see no problem, but maybe there are some  
> inmprovements needed in
> the ssh application before it will work smoothly.
>
>> 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.
>
> There might be a problem here we will look into it.
>
> Regards Ingela Erlang/OTP - Ericsson
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2419 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081111/0eb46823/attachment.bin>


More information about the erlang-questions mailing list