Skip to content

Commit

Permalink
Merge pull request hashicorp#5887 from msabramo/config.ssh.ssh_command
Browse files Browse the repository at this point in the history
Add setting config.ssh.ssh_command
  • Loading branch information
mitchellh committed Jul 9, 2015
2 parents 3cd12b4 + 9240ea3 commit 3cad495
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/vagrant/machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ def ssh_info
info[:forward_agent] = @config.ssh.forward_agent
info[:forward_x11] = @config.ssh.forward_x11

info[:ssh_command] = @config.ssh.ssh_command if @config.ssh.ssh_command

# Add in provided proxy command config
info[:proxy_command] = @config.ssh.proxy_command if @config.ssh.proxy_command

Expand Down
11 changes: 7 additions & 4 deletions lib/vagrant/util/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,20 @@ def self.exec(ssh_info, opts={})
# we really don't care since both work.
ENV["nodosfilewarning"] = "1" if Platform.cygwin?

ssh = ssh_info[:ssh_command] || 'ssh'

# Invoke SSH with all our options
if !opts[:subprocess]
LOGGER.info("Invoking SSH: #{command_options.inspect}")
SafeExec.exec("ssh", *command_options)
LOGGER.info("Invoking SSH: #{ssh} #{command_options.inspect}")
# msabramo
SafeExec.exec(ssh, *command_options)
return
end

# If we're still here, it means we're supposed to subprocess
# out to ssh rather than exec it.
LOGGER.info("Executing SSH in subprocess: #{command_options.inspect}")
process = ChildProcess.build("ssh", *command_options)
LOGGER.info("Executing SSH in subprocess: #{ssh} #{command_options.inspect}")
process = ChildProcess.build(ssh, *command_options)
process.io.inherit!
process.start
process.wait
Expand Down
3 changes: 2 additions & 1 deletion plugins/commands/ssh_config/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def execute
private_key_path: ssh_info[:private_key_path],
forward_agent: ssh_info[:forward_agent],
forward_x11: ssh_info[:forward_x11],
proxy_command: ssh_info[:proxy_command]
proxy_command: ssh_info[:proxy_command],
ssh_command: ssh_info[:ssh_command]
}

# Render the template and output directly to STDOUT
Expand Down
3 changes: 3 additions & 0 deletions plugins/kernel_v2/config/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SSHConfig < SSHConnectConfig
attr_accessor :keep_alive
attr_accessor :shell
attr_accessor :proxy_command
attr_accessor :ssh_command
attr_accessor :pty
attr_accessor :sudo_command

Expand All @@ -24,6 +25,7 @@ def initialize
@guest_port = UNSET_VALUE
@keep_alive = UNSET_VALUE
@proxy_command = UNSET_VALUE
@ssh_command = UNSET_VALUE
@pty = UNSET_VALUE
@shell = UNSET_VALUE
@sudo_command = UNSET_VALUE
Expand All @@ -46,6 +48,7 @@ def finalize!
@guest_port = 22 if @guest_port == UNSET_VALUE
@keep_alive = true if @keep_alive == UNSET_VALUE
@proxy_command = nil if @proxy_command == UNSET_VALUE
@ssh_command = nil if @ssh_command == UNSET_VALUE
@pty = false if @pty == UNSET_VALUE
@shell = "bash -l" if @shell == UNSET_VALUE

Expand Down

0 comments on commit 3cad495

Please sign in to comment.