Sha256: 184a3ed1d36069418e81d0283b0daaa4b785983381edb86fe64844752325814a
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require "net/ssh" class Kraaken::Ssh def initialize(config:) @config = config end def regenerate_config servers = config.cloud.servers jump = servers.find(&:jump?) servers.reject!(&:jump?) config = <<~SSH Host jump User root HostName #{jump.public_ip} ForwardAgent yes SSH servers.each do |server| config += <<~SSH Host #{server.name} User nerd HostName #{server.ip} ProxyJump jump SSH end File.write(File.join(Dir.home, ".ssh", "cloud_config"), config) config_path = File.join(Dir.home, ".ssh", "config") unless File.read(config_path).include?("Include cloud_config") File.write(config_path, "Include cloud_config\n\n" + File.read(config_path)) end end def connect(name) result = nil Net::SSH.start(name) do |ssh| result = yield Kraaken::Ssh::Connection.new(ssh, logger: config.logger) if block_given? end result end private attr_reader :config end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kraaken-0.0.1 | lib/kraaken/ssh.rb |