views:

123

answers:

2

I would like to reset passwords on a bunch of boxes over SSH. Any pointers on how Erlang could be used for this purpose?

A: 
Roberto Aloi
Please see the comment above.
tbikeev
the FAQ saying it's not made for exactly that purpose is no indication of how appropriate a language is. the tools are there to solve it and the "not particularly suitable for" section doesn't even apply.
Felix Lange
And the question is actually "how can I use Erlang for this...", not "should I use Erlang for this..."
Adam Lindberg
Fair enough. This was just my opinion, emerged after using Erlang ssh for similar things and realizing that other alternatives could have worked as well in a simpler way. Mine was more a comment rather than a question, but it was too long to put it there :)
Roberto Aloi
+1  A: 

Erlang is indeed a well-suited choice for this problem.

You should have a look at the ssh module. Start a connection with

ssh:connect(Host, Port, Options).

Then use the ssh_connection module to execute the right passwd command (hint: start a shell first) and log out.

Edit: The above is mostly wrong, this blog post might get you started faster.

You can even write a simple server that does all of these things on several hosts in parallel, resulting in the most multicore-capable multi-host ssh password changer on this very planet. Weekend project idea: make a web app out of it.

Felix Lange
I just hope he doesn't have to deal with public keys protected by a password, since they are not handled by the entire ssh application (unless the OTP team recently introduced it)...
Roberto Aloi
Well, unfortunately I need to cover for the cases like: password-expired-pls-provide-new-validate-re-login hence the whole "expect" question.
tbikeev
once you're connected, you can do pretty much anything.
Felix Lange