Added -J for ssh proxy
This commit is contained in:
@@ -9,7 +9,13 @@ module Mrsk::Commands
|
|||||||
end
|
end
|
||||||
|
|
||||||
def run_over_ssh(command, host:)
|
def run_over_ssh(command, host:)
|
||||||
"ssh -t #{config.ssh_user}@#{host} '#{command}'"
|
ssh_command = "ssh"
|
||||||
|
|
||||||
|
if config.ssh_proxy
|
||||||
|
ssh_command << " -J #{config.ssh_proxy.jump_proxies}"
|
||||||
|
end
|
||||||
|
|
||||||
|
ssh_command << " -t #{config.ssh_user}@#{host} '#{command}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -38,4 +38,14 @@ class CommandsAppTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
assert @app.run.exclude?("RAILS_MASTER_KEY=456")
|
assert @app.run.exclude?("RAILS_MASTER_KEY=456")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "exec_over_ssh" do
|
||||||
|
assert @app.exec_over_ssh("ls", host: '1.1.1.1').start_with?("ssh -t #{@app.config.ssh_user}@1.1.1.1")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "exec_over_ssh with proxy" do
|
||||||
|
@app = Mrsk::Commands::App.new Mrsk::Configuration.new(@config.tap { |c| c[:ssh] = { "proxy" => 'root@2.2.2.2' } })
|
||||||
|
|
||||||
|
assert @app.exec_over_ssh("ls", host: '1.1.1.1').start_with?("ssh -J root@2.2.2.2 -t #{@app.config.ssh_user}@1.1.1.1")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user