summaryrefslogtreecommitdiff
path: root/lib/leap_cli/commands/shell.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/leap_cli/commands/shell.rb')
-rw-r--r--lib/leap_cli/commands/shell.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/leap_cli/commands/shell.rb b/lib/leap_cli/commands/shell.rb
index a84c671..f73a706 100644
--- a/lib/leap_cli/commands/shell.rb
+++ b/lib/leap_cli/commands/shell.rb
@@ -2,10 +2,19 @@ module LeapCli; module Commands
desc 'Log in to the specified node with an interactive shell'
arg_name '<node-name>', :optional => false, :multiple => false
- command :shell, :ssh do |c|
+ command :ssh do |c|
c.action do |global_options,options,args|
node = get_node_from_args(args)
- exec "ssh -l root -o 'HostName=#{node.ip_address}' -o 'HostKeyAlias=#{node.name}' -o 'GlobalKnownHostsFile=#{path(:known_hosts)}' -o 'StrictHostKeyChecking=yes' -p #{node.ssh.port} #{node.name}"
+ options = [
+ "-o 'HostName=#{node.ip_address}'",
+ "-o 'HostKeyAlias=#{node.name}'",
+ "-o 'GlobalKnownHostsFile=#{path(:known_hosts)}'",
+ "-o 'StrictHostKeyChecking=yes'"
+ ]
+ if node.vagrant?
+ options << "-i #{vagrant_ssh_key_file}"
+ end
+ exec "ssh -l root -p #{node.ssh.port} #{options.join(' ')} {node.name}"
end
end