Working secrets implementation

This commit is contained in:
2021-04-20 17:53:25 -07:00
parent 951ffa3ff9
commit 353936d509
6 changed files with 242 additions and 59 deletions
+11 -9
View File
@@ -43,9 +43,10 @@ OptionParser.new do |opts|
options[:ipv6] = true
end
opts.on("-f", "--sshfp",
"Register host SSH key fingerprints with the backplane.") do
options[:sshfp] = true
opts.on("-f", "--sshfp=FILE",
"Register host SSH key fingerprints with the backplane.") do |file|
options[:sshfp] = [] if not options[:sshfp]
options[:sshfp] = options[:sshfp] + [file]
end
end.parse!
@@ -217,11 +218,12 @@ def interface_addresses(interface)
end
end
def host_sshfp
keys = `ssh-keygen -r hostname`.split("\n").map do |k|
k.match(/[0-9] [0-9] [a-fA-F0-9]{32,64}$/)[0]
end
keys.compact
def host_sshfp(keys)
keys.flat_map { |keyfile|
`ssh-keygen -r hostname #{keyfile}`.split("\n")
}.map { |fp|
fp..match(/[0-9] [0-9] [a-fA-F0-9]{32,64}$/)[0]
}.compact
end
def hostname
@@ -275,7 +277,7 @@ begin
end
if options[:sshfp]
fps = host_sshfp
fps = host_sshfp(options[:sshfp])
if not fps.empty?
puts "#{options[:server]}: #{hostname}.#{options[:domain]} IN SSHFP => #{fps}"
if client.send_sshfp(fps)