From 0cd48a7aff2f286ab623d04ea6758e3ac27506fd Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Fri, 21 May 2021 12:19:36 +0200 Subject: [PATCH] M #-: add SSH options to onevm ssh (#1239) (cherry picked from commit 014d12524147f07f2f0c24fe657c893da933edc5) --- src/cli/onevm | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/cli/onevm b/src/cli/onevm index 097b38fd08..3cee2b84e6 100755 --- a/src/cli/onevm +++ b/src/cli/onevm @@ -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