From 8fe7bc1df1e58fa68651f29a0f75ecd7454d742f Mon Sep 17 00:00:00 2001 From: elijah Date: Mon, 29 Oct 2012 13:23:56 -0700 Subject: respect configured ssh port when doing keyscan --- lib/leap_cli/commands/node.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb index 57c826e..de6adad 100644 --- a/lib/leap_cli/commands/node.rb +++ b/lib/leap_cli/commands/node.rb @@ -85,7 +85,7 @@ module LeapCli; module Commands # def save_public_host_key(node) progress("Fetching public SSH host key for #{node.name}") - public_key = get_public_key_for_ip(node.ip_address) + public_key = get_public_key_for_ip(node.ip_address, node.ssh.port) pub_key_path = Path.named_path([:node_ssh_pub_key, node.name]) if Path.exists?(pub_key_path) if public_key == SshKey.load_from_file(pub_key_path) @@ -110,9 +110,9 @@ module LeapCli; module Commands end end - def get_public_key_for_ip(address) + def get_public_key_for_ip(address, port=22) assert_bin!('ssh-keyscan') - output = assert_run! "ssh-keyscan -t rsa #{address}", "Could not get the public host key. Maybe sshd is not running?" + output = assert_run! "ssh-keyscan -p #{port} -t rsa #{address}", "Could not get the public host key from #{address}:#{port}. Maybe sshd is not running?" line = output.split("\n").grep(/^[^#]/).first assert! line, "Got zero host keys back!" ip, key_type, public_key = line.split(' ') -- cgit v1.2.3