aboutsummaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/compile.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-11-05 15:44:24 -0800
committerelijah <elijah@riseup.net>2014-11-05 15:44:24 -0800
commit2c697c574a6844c6cec3dc0cb6498cc0f87ff072 (patch)
tree7bac92e321c42f5147c481afd5905b317cc52768 /lib/leap_cli/commands/compile.rb
parent1ba5abc1a9359a00cee2da06b9766eb0bdda9f29 (diff)
downloadleap_cli-2c697c574a6844c6cec3dc0cb6498cc0f87ff072.tar.gz
leap_cli-2c697c574a6844c6cec3dc0cb6498cc0f87ff072.tar.bz2
prompt user to update ssh host keys when a better one is available. closes #6320
Diffstat (limited to 'lib/leap_cli/commands/compile.rb')
-rw-r--r--lib/leap_cli/commands/compile.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/leap_cli/commands/compile.rb b/lib/leap_cli/commands/compile.rb
index 644ce2a..b30aaea 100644
--- a/lib/leap_cli/commands/compile.rb
+++ b/lib/leap_cli/commands/compile.rb
@@ -98,6 +98,30 @@ module LeapCli
write_file!(:authorized_keys, buffer.string)
end
+ #
+ # generates the known_hosts file.
+ #
+ # we do a 'late' binding on the hostnames and ip part of the ssh pub key record in order to allow
+ # for the possibility that the hostnames or ip has changed in the node configuration.
+ #
+ def update_known_hosts
+ buffer = StringIO.new
+ buffer << "#\n"
+ buffer << "# This file is automatically generated by the command `leap`. You should NOT modify this file.\n"
+ buffer << "# Instead, rerun `leap node init` on whatever node is causing SSH problems.\n"
+ buffer << "#\n"
+ manager.nodes.keys.sort.each do |node_name|
+ node = manager.nodes[node_name]
+ hostnames = [node.name, node.domain.internal, node.domain.full, node.ip_address].join(',')
+ pub_key = read_file([:node_ssh_pub_key,node.name])
+ if pub_key
+ buffer << [hostnames, pub_key].join(' ')
+ buffer << "\n"
+ end
+ end
+ write_file!(:known_hosts, buffer.string)
+ end
+
##
## ZONE FILE
##