lib/vagrant/ssh.rb
# Connects to the environment's virtual machine, replacing the ruby
# process with an SSH process. This method optionally takes a hash
# of options which override the configuration values.
Connects to the environment's virtual machine, replacing the ruby
process with an SSH process. This method optionally takes a hash
of options which override the configuration values.
Connects to the environment ' s virtual machine replacing the ruby process with an SSH process . This method optionally takes a hash of options which override the configuration values .
def connect(opts={})
      if Mario::Platform.windows?
        raise Errors::SSHUnavailableWindows, :key_path => env.config.ssh.private_key_path,
                                             :ssh_port => port(opts)
      end
      raise Errors::SSHUnavailable if !Kernel.system("which ssh > /dev/null 2>&1")
      options = {}
      options[:port] = port(opts)
      [:host, :username, :private_key_path].each do |param|
        options[param] = opts[param] || env.config.ssh.send(param)
      end
      check_key_permissions(options[:private_key_path])
      command_options = ["-p #{options[:port]}", "-o UserKnownHostsFile=/dev/null",
                         "-o StrictHostKeyChecking=no", "-o IdentitiesOnly=yes",
                         "-i #{options[:private_key_path]}"]
      command_options << "-o ForwardAgent=yes" if env.config.ssh.forward_agent
      if env.config.ssh.forward_x11
        command_options << "-o ForwardX11=yes"
        command_options << "-o ForwardX11Trusted=yes"
      end
      pid = nil
      pid = fork if Util::Platform.leopard? || Util::Platform.tiger?
      Kernel.exec "ssh #{command_options.join(" ")} #{options[:username]}@#{options[:host]}".strip if pid.nil?
      Process.wait(pid) if pid
    end
def connect ( opts = { } ) if Mario :: Platform . windows? raise Errors :: SSHUnavailableWindows , :key_path => env . config . ssh . private_key_path , :ssh_port => port ( opts ) end raise Errors :: SSHUnavailable if ! Kernel . system ( "which ssh > /dev/null 2>&1" ) options = { } options [ :port ] = port ( opts ) [ :host , :username , :private_key_path ] . each do | param | options [ param ] = opts [ param ] || env . config . ssh . send ( param ) end check_key_permissions ( options [ :private_key_path ] ) command_options = [ "-p #{options[:port]}" , "-o UserKnownHostsFile=/dev/null" , "-o StrictHostKeyChecking=no" , "-o IdentitiesOnly=yes" , "-i #{options[:private_key_path]}" ] command_options << "-o ForwardAgent=yes" if env . config . ssh . forward_agent if env . config . ssh . forward_x11 command_options << "-o ForwardX11=yes" command_options << "-o ForwardX11Trusted=yes" end pid = nil pid = fork if Util :: Platform . leopard? || Util :: Platform . tiger? Kernel . exec "ssh #{command_options.join(" ")} #{options[:username]}@#{options[:host]}" . strip if pid . nil? Process . wait ( pid ) if pid end
Connects to the environment's virtual machine, replacing the ruby
process with an SSH process.
Connects to the environment ' s virtual machine replacing the ruby process with an SSH process .
# Command line options # Both are required so that no warnings are shown regarding X11 # Some hackery going on here. On Mac OS X Leopard (10.5), exec fails # (GH-51). As a workaround, we fork and wait. On all other platforms, # we simply exec.
opts
<not_specific>