summaryrefslogtreecommitdiff
path: root/lib/leap_cli
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-10-29 13:23:56 -0700
committerelijah <elijah@riseup.net>2012-10-29 13:23:56 -0700
commit8fe7bc1df1e58fa68651f29a0f75ecd7454d742f (patch)
treef698e10fe6638b309917b580c6e01d190a5bbbc7 /lib/leap_cli
parent7d78ba9f3a684b1227f362d923ca536bab487d91 (diff)
respect configured ssh port when doing keyscan
Diffstat (limited to 'lib/leap_cli')
-rw-r--r--lib/leap_cli/commands/node.rb6
1 files changed, 3 insertions, 3 deletions
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(' ')