]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
make sure to specify HostKeyAlgorithms for ssh and rsync. this is needed because...
authorelijah <elijah@riseup.net>
Sun, 9 Nov 2014 23:18:18 +0000 (15:18 -0800)
committerelijah <elijah@riseup.net>
Sun, 9 Nov 2014 23:18:18 +0000 (15:18 -0800)
lib/leap_cli/commands/shell.rb
lib/leap_cli/config/node.rb
lib/leap_cli/ssh_key.rb
lib/leap_cli/util/remote_command.rb

index 2138e9d6b1a620cd5a6a7a983940aeb1b946a178..a7a0d85ca5a8ee99fed9247a02579e91d490be0e 100644 (file)
@@ -62,6 +62,9 @@ module LeapCli; module Commands
     else
       options << "-o 'StrictHostKeyChecking=yes'"
     end
+    if !node.supported_ssh_host_key_algorithms.empty?
+      options << "-o 'HostKeyAlgorithms=#{node.supported_ssh_host_key_algorithms}'"
+    end
     username = 'root'
     if LeapCli.log_level >= 3
       options << "-vv"
index 30af5d19ea0645493abcf49c7e0490291fd99d7f..fe685cfb3dc8a5c08d71c6f076e4f27a93c07805 100644 (file)
@@ -63,6 +63,15 @@ module LeapCli; module Config
     def test_dependencies
       []
     end
+
+    # returns a string list of supported ssh host key algorithms for this node.
+    # or an empty string if it could not be determined
+    def supported_ssh_host_key_algorithms
+      @host_key_algo ||= SshKey.supported_host_key_algorithms(
+        Util.read_file([:node_ssh_pub_key, @node.name])
+      )
+    end
+
   end
 
 end; end
index 3cbeddd2ad713c2fcbc0232905983ced648c8733..5a7ac23894f2934d53bc8eaff657bd252522e40c 100644 (file)
@@ -107,6 +107,23 @@ module LeapCli
       return keys.map{|k| SshKey.load(k[1], k[0])}
     end
 
+    #
+    # takes a string with one or more ssh keys, one key per line,
+    # and returns a string that specified the ssh key algorithms
+    # that are supported by the keys, in order of preference.
+    #
+    # eg: ecdsa-sha2-nistp256,ssh-rsa,ssh-ed25519
+    #
+    def self.supported_host_key_algorithms(string)
+      if string
+        self.parse_keys(string).map {|key|
+          key.type
+        }.join(',')
+      else
+        ""
+      end
+    end
+
     ##
     ## INSTANCE METHODS
     ##
index 2dd22ca313731502bef533621aa9e6a78a21797c..16d2b22146dfd3ea3f1b12f0d8cdaa9fba8732d9 100644 (file)
@@ -149,6 +149,9 @@ module LeapCli; module Util; module RemoteCommand
         opts[:verbose] = :error # suppress all the warnings about adding host keys to known_hosts, since it is not actually doing that.
       end
     end
+    if !node.supported_ssh_host_key_algorithms.empty?
+      opts[:host_key] = node.supported_ssh_host_key_algorithms
+    end
     return opts
   end