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

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

This commit is contained in:
Alejandro Huertas Herrero 2021-05-21 12:19:36 +02:00 committed by GitHub
parent 24ca6db51c
commit 014d125241
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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