Allow use of bastion host

This commit is contained in:
Chris de Bruin
2023-01-27 10:07:24 +01:00
parent 2023c377ab
commit 1fef6ba505
3 changed files with 44 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ require "active_support/core_ext/module/delegation"
require "pathname"
require "erb"
require "mrsk/utils"
require "net/ssh/proxy/jump"
class Mrsk::Configuration
delegate :service, :image, :servers, :env, :labels, :registry, :builder, to: :raw_config, allow_nil: true
@@ -104,11 +105,33 @@ class Mrsk::Configuration
end
def ssh_user
raw_config.ssh_user || "root"
if raw_config.ssh.present?
raw_config.ssh["user"] || "root"
else
"root"
end
end
def ssh_options
{ user: ssh_user, auth_methods: [ "publickey" ] }
options = { user: ssh_user, auth_methods: [ "publickey" ] }
options[:proxy] = ::Net::SSH::Proxy::Jump.new(ssh_proxy_host) if ssh_proxy_host
options
end
def ssh_proxy_host
if raw_config.ssh && raw_config.ssh["proxy_host"]
"#{ssh_user_proxy_host}@#{raw_config.ssh['proxy_host']}"
end
end
def ssh_user_proxy_host
if raw_config.ssh.present?
raw_config.ssh["user_proxy_host"] || "root"
else
"root"
end
end
def master_key