]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
fix longstanding problem with vagrant nodes: everyone has a different ssh pub key...
authorelijah <elijah@riseup.net>
Tue, 11 Jun 2013 19:24:42 +0000 (12:24 -0700)
committerelijah <elijah@riseup.net>
Tue, 11 Jun 2013 19:24:42 +0000 (12:24 -0700)
lib/leap_cli/commands/node.rb
lib/leap_cli/commands/shell.rb
lib/leap_cli/util/remote_command.rb
vendor/rsync_command/lib/rsync_command/ssh_options.rb

index 4b5ea9eec1b3468608be33a6ede2c3ba601615c5..1f94fe6a8da1552e50e75844229fee353e2a3da5 100644 (file)
@@ -60,7 +60,7 @@ module LeapCli; module Commands
         finished = []
         manager.filter!(args).each_node do |node|
           ping_node(node, options) unless options[:noping]
-          save_public_host_key(node, global, options)
+          save_public_host_key(node, global, options) unless node.vagrant?
           update_compiled_ssh_configs
           ssh_connect_options = connect_options(options).merge({:bootstrap => true, :echo => options[:echo]})
           ssh_connect(node, ssh_connect_options) do |ssh|
index 822ef05593bd3c8165f59ebc9a75a11506844db0..3a6cebcc14f3d58091d27e7e64c9480df9e9cffe 100644 (file)
@@ -39,11 +39,14 @@ module LeapCli; module Commands
     options = [
       "-o 'HostName=#{node.ip_address}'",
       "-o 'HostKeyAlias=#{node.name}'",
-      "-o 'GlobalKnownHostsFile=#{path(:known_hosts)}'",
-      "-o 'StrictHostKeyChecking=yes'"
+      "-o 'GlobalKnownHostsFile=#{path(:known_hosts)}'"
     ]
     if node.vagrant?
       options << "-i #{vagrant_ssh_key_file}"
+      options << "-o 'StrictHostKeyChecking=no'"      # \ together, these options allow us to just blindly accept
+      options << "-o 'UserKnownHostsFile=/dev/null'"  # / what pub key the vagrant node has. useful, because it is different for everyone.
+    else
+      options << "-o 'StrictHostKeyChecking=yes'"
     end
     username = 'root'
     # the echo sets the terminal title. it would be better to do this on the server
index 2c77196abff2359b1ded90998027e72deae55c55..1197bfe7aa2d0c8aed88bbc96f4e65c680561304 100644 (file)
@@ -46,6 +46,7 @@ module LeapCli; module Util; module RemoteCommand
     {
       :config => false,
       :global_known_hosts_file => path(:known_hosts),
+      :user_known_hosts_file => '/dev/null',
       :paranoid => true
     }
   end
@@ -95,11 +96,15 @@ module LeapCli; module Util; module RemoteCommand
   end
 
   def contingent_ssh_options_for_node(node)
+    opts = {}
     if node.vagrant?
-      {:keys => [vagrant_ssh_key_file]}
-    else
-      {}
+      opts[:keys] = [vagrant_ssh_key_file]
+      opts[:paranoid] = false # we skip host checking for vagrant nodes, because fingerprint is different for everyone.
+      if LeapCli::log_level <= 1
+        opts[:verbose] = :error # suppress all the warnings about adding host keys to known_hosts, since it is not actually doing that.
+      end
     end
+    return opts
   end
 
 end; end; end
\ No newline at end of file
index 494ec9ddb90ec6a98c90f3dfbff7b9811659ff05..3cc908fe98cf0f543c2d3cb09d4e81f5b373a803 100644 (file)
@@ -32,14 +32,14 @@ class RsyncCommand
 
     def parse_options(options)
       options.map do |key, value|
-        next unless value
+        next if value.nil?
         # Convert Net::SSH options into OpenSSH options.
         case key
         when :auth_methods            then opt_auth_methods(value)
         when :bind_address            then opt('BindAddress', value)
         when :compression             then opt('Compression', value ? 'yes' : 'no')
         when :compression_level       then opt('CompressionLevel', value.to_i)
-        when :config                  then "-F '#{value}'"
+        when :config                  then value ? "-F '#{value}'" : nil
         when :encryption              then opt('Ciphers', [value].flatten.join(','))
         when :forward_agent           then opt('ForwardAgent', value)
         when :global_known_hosts_file then opt('GlobalKnownHostsFile', value)