diff options
| author | elijah <elijah@riseup.net> | 2014-06-26 09:51:52 -0700 | 
|---|---|---|
| committer | elijah <elijah@riseup.net> | 2014-06-26 09:51:52 -0700 | 
| commit | 390f59b1c26fa3bcc4b0b38e9f69666dd69d8814 (patch) | |
| tree | f97eea4ffd162813211f24e2f5e5e83dd317bb40 /lib/leap_cli | |
| parent | 56f58507bd5c0d25108443d083b26397ad30dcc3 (diff) | |
allows custom passthrough options for `leap ssh`. closes #5578
Diffstat (limited to 'lib/leap_cli')
| -rw-r--r-- | lib/leap_cli/commands/shell.rb | 17 | 
1 files changed, 13 insertions, 4 deletions
| diff --git a/lib/leap_cli/commands/shell.rb b/lib/leap_cli/commands/shell.rb index 2ccb3de..2138e9d 100644 --- a/lib/leap_cli/commands/shell.rb +++ b/lib/leap_cli/commands/shell.rb @@ -3,8 +3,10 @@ module LeapCli; module Commands    desc 'Log in to the specified node with an interactive shell.'    arg_name 'NAME' #, :optional => false, :multiple => false    command :ssh do |c| +    c.flag 'ssh', :desc => "Pass through raw options to ssh (e.g. --ssh '-F ~/sshconfig')" +    c.flag 'port', :desc => 'Override ssh port for remote host'      c.action do |global_options,options,args| -      exec_ssh(:ssh, args) +      exec_ssh(:ssh, options, args)      end    end @@ -12,7 +14,7 @@ module LeapCli; module Commands    arg_name 'NAME'    command :mosh do |c|      c.action do |global_options,options,args| -      exec_ssh(:mosh, args) +      exec_ssh(:mosh, options, args)      end    end @@ -44,8 +46,9 @@ module LeapCli; module Commands    private -  def exec_ssh(cmd, args) +  def exec_ssh(cmd, cli_options, args)      node = get_node_from_args(args, :include_disabled => true) +    port = node.ssh.port      options = [        "-o 'HostName=#{node.ip_address}'",        # "-o 'HostKeyAlias=#{node.name}'", << oddly incompatible with ports in known_hosts file, so we must not use this or non-standard ports break. @@ -65,7 +68,13 @@ module LeapCli; module Commands      elsif LeapCli.log_level >= 2        options << "-v"      end -    ssh = "ssh -l #{username} -p #{node.ssh.port} #{options.join(' ')}" +    if cli_options[:port] +      port = cli_options[:port] +    end +    if cli_options[:ssh] +      options << cli_options[:ssh] +    end +    ssh = "ssh -l #{username} -p #{port} #{options.join(' ')}"      if cmd == :ssh        command = "#{ssh} #{node.domain.full}"      elsif cmd == :mosh | 
