1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

M #-: add SSH options to onevm ssh (#1239)

(cherry picked from commit 014d12524147f07f2f0c24fe657c893da933edc5)
This commit is contained in:
Alejandro Huertas Herrero 2021-05-21 12:19:36 +02:00 committed by Ruben S. Montero
parent 147b7f8b32
commit 0cd48a7aff
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -232,6 +232,13 @@ CommandParser::CmdParser.new(ARGV) do
:description => 'CMD to run when SSH'
}
SSH_OPTS = {
:name => 'ssh_opts',
:large => '--ssh-options options',
:format => String,
:description => 'SSH options to use'
}
########################################################################
# Global Options
########################################################################
@ -1553,9 +1560,17 @@ CommandParser::CmdParser.new(ARGV) do
ssh_desc = <<-EOT.unindent
SSH into VM
Options example:
'-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'
EOT
command :ssh, ssh_desc, :vmid, [:login, nil], :options => [NIC_ID, CMD] do
command :ssh,
ssh_desc,
:vmid,
[:login, nil],
:options => [NIC_ID, CMD, SSH_OPTS] do
helper.perform_action(args[0], options, 'SSH') do |vm|
rc = vm.info
@ -1596,7 +1611,9 @@ CommandParser::CmdParser.new(ARGV) do
port = 22
end
system("ssh #{login}@#{ip} -p #{port} #{cmd}")
options[:ssh_opts].nil? ? opts = '' : opts = options[:ssh_opts]
system("ssh #{opts} #{login}@#{ip} -p #{port} #{cmd}")
end
$?.exitstatus