Thanks Jamis, that helps a lot! Jerod Santo http://jerodsanto.net
On Tue, Feb 10, 2009 at 11:12 AM, Jamis Buck <[email protected]> wrote: > > Just capture it and reuse: > > password = nil > confirmation = nil > > run "passwd", :pty => true do |ch, stream, data| > if data =~ /Enter new UNIX password:/ > password ||= Capistrano::CLI.password_prompt( > "New root password: ") > ch.send_data(password + "\n") > elsif data =~ /Retype new UNIX password:/ > confirmation ||= Capistrano::CLI.password_prompt( > "Retype new root password: ") > ch.send_data(confirmation + "\n") > else > Capistrano::Configuration.default_io_proc.call(ch, stream, data) > end > end > > I'll leave as an exercise for the reader how to handle the case where > the password and the confirmation do not match, and passwd tries to > reprompt. > > - Jamis > > On 2/10/09 9:56 AM, Jerod Santo wrote: > > Jamis- > > > > That is a nice way to handle the required input by passwd, but it > > doesn't quite get me where I want to go, because I will have to type the > > new password n times. Is there a way to prompt once and capture, then > > just send the captured output through the data channel for subsequent > > requests? > > > > > > Jerod Santo > > http://jerodsanto.net > > > > > > On Tue, Feb 10, 2009 at 10:43 AM, Jamis Buck <[email protected] > > <mailto:[email protected]>> wrote: > > > > > > Here's how I've done that in the past: > > > > run "passwd", :pty => true do |ch, stream, data| > > if data =~ /Enter new UNIX password:/ > > ch.send_data(Capistrano::CLI.password_prompt( > > "New root password: ") + "\n") > > elsif data =~ /Retype new UNIX password:/ > > ch.send_data(Capistrano::CLI.password_prompt( > > "Retype new root password: ") + "\n") > > else > > Capistrano::Configuration.default_io_proc.call(ch, stream, data) > > end > > end > > > > Here's a pastie, if the above didn't get formatted well by your email > > client: > > > > http://pastie.org/385103 > > > > - Jamis > > > > On 2/10/09 9:39 AM, sant0sk1 wrote: > > > A use case: > > > > > > There are n debian servers being managed on a LAN and the admin > wants > > > to synchronize their root user's password using Capistrano. The > user > > > wants to execute something like: cap ROLES=debian set_root_pw. The > > > user is then prompted for the new password one time (with > > > confirmation) and the password is changed on all n machines. > > > > > > I'd like to implement something like this but I can't seem to find > a > > > non-interactive 'passwd' method. Are there other ways to get this > > > done? One thought is to generate the hashed password locally and > have > > > Cap edit the /etc/shadow files of all the remote hosts. Not sure if > > > that would work with salting and whatnot. Any other ideas of how to > > > get this done? > > > > > > Thanks guys. Love Cap! > > > > > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/capistrano -~----------~----~----~----~------~----~------~--~---
