summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-29 13:17:34 -0700
committerelijah <elijah@riseup.net>2012-10-29 13:17:34 -0700
commit7d78ba9f3a684b1227f362d923ca536bab487d91 (patch)
treeb821e5852a12bd8206213d49afb76deda82257e9 /lib
parentcd7a9e75064947ec6ea426623b4774cce63f4b5e (diff)
make typed passwords invisible again (use --echo to make them visible)
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/node.rb3
-rw-r--r--lib/leap_cli/commands/util.rb15
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb
index b9640a8..57c826e 100644
--- a/lib/leap_cli/commands/node.rb
+++ b/lib/leap_cli/commands/node.rb
@@ -16,12 +16,13 @@ module LeapCli; module Commands
desc 'Bootstraps a node, setting up ssh keys and installing prerequisites'
arg_name '<node-name>', :optional => false, :multiple => false
command :'init-node' do |c|
+ c.switch 'echo', :desc => 'if set, passwords are visible as you type them (default is hidden)', :negatable => false
c.action do |global_options,options,args|
node = get_node_from_args(args)
ping_node(node)
save_public_host_key(node)
update_compiled_ssh_configs
- ssh_connect(node, :bootstrap => true) do |ssh|
+ ssh_connect(node, :bootstrap => true, :echo => options[:echo]) do |ssh|
ssh.install_authorized_keys
ssh.install_prerequisites
end
diff --git a/lib/leap_cli/commands/util.rb b/lib/leap_cli/commands/util.rb
index aa888e0..d9e6923 100644
--- a/lib/leap_cli/commands/util.rb
+++ b/lib/leap_cli/commands/util.rb
@@ -67,8 +67,13 @@ module LeapCli; module Commands
#
if options[:bootstrap] && node_list.size == 1
hostname = node_list.values.first.name
- cap.set(:password) { ask("SSH password for #{user}@#{hostname}> ") } # only called if needed
- # this can be used instead to hide echo -- Capistrano::CLI.password_prompt
+
+ # the 'password' block is only called if key auth fails
+ if options[:echo]
+ cap.set(:password) { ask "Root SSH password for #{user}@#{hostname}> " }
+ else
+ cap.set(:password) { Capistrano::CLI.password_prompt " * Typed password will be hidden (use --echo to make it visible)\nRoot SSH password for #{user}@#{hostname}> " }
+ end
end
node_list.each do |name, node|
@@ -98,9 +103,9 @@ module LeapCli; module Commands
# http://railsware.com/blog/2011/11/02/advanced-server-definitions-in-capistrano/
#
def node_options(node)
- password_proc = Proc.new {Capistrano::CLI.password_prompt "Root SSH password for #{node.name}"} # only called if needed
+ #password_proc = Proc.new {Capistrano::CLI.password_prompt "Root SSH password for #{node.name}"} # only called if needed
{
- :password => password_proc,
+ #:password => password_proc,
:ssh_options => {
:host_key_alias => node.name,
:host_name => node.ip_address,
@@ -113,7 +118,7 @@ module LeapCli; module Commands
# load once the library files
@capistrano_enabled ||= begin
require 'capistrano'
- #require 'capistrano/cli'
+ require 'capistrano/cli'
require 'leap_cli/remote/plugin'
Capistrano.plugin :leap, LeapCli::Remote::Plugin
true