Send SSH keep-alive packets [GH-516]
This commit is contained in:
parent
47dfd81fd1
commit
7fa9892b75
|
@ -45,6 +45,8 @@ IMPROVEMENTS:
|
|||
- Detect PuTTY Link SSH client on Windows and show an error. [GH-1518]
|
||||
- `vagrant ssh` in Cygwin won't output DOS path file warnings.
|
||||
- Add `--rtcuseutc on` as a sane default for VirtualBox. [GH-912]
|
||||
- SSH will send keep-alive packets every 5 seconds by default to
|
||||
keep connections alive. Can be disabled with `config.ssh.keep_alive`. [GH-516]
|
||||
|
||||
BUG FIXES:
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ Vagrant.configure("2") do |config|
|
|||
|
||||
config.ssh.username = "vagrant"
|
||||
config.ssh.guest_port = 22
|
||||
config.ssh.keep_alive = true
|
||||
config.ssh.max_tries = 100
|
||||
config.ssh.timeout = 30
|
||||
config.ssh.forward_agent = false
|
||||
|
|
|
@ -295,8 +295,28 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
# Wait for the channel to complete
|
||||
channel.wait
|
||||
begin
|
||||
keep_alive = nil
|
||||
|
||||
if @machine.config.ssh.keep_alive
|
||||
# Begin sending keep-alive packets while we wait for the script
|
||||
# to complete. This avoids connections closing on long-running
|
||||
# scripts.
|
||||
keep_alive = Thread.new do
|
||||
loop do
|
||||
sleep 5
|
||||
@logger.debug("Sending SSH keep-alive...")
|
||||
connection.send_global_request("keep-alive@openssh.com")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Wait for the channel to complete
|
||||
channel.wait
|
||||
ensure
|
||||
# Kill the keep-alive thread
|
||||
keep_alive.kill if keep_alive
|
||||
end
|
||||
|
||||
# Return the final exit status
|
||||
return exit_status
|
||||
|
|
|
@ -7,6 +7,7 @@ module VagrantPlugins
|
|||
attr_accessor :forward_x11
|
||||
attr_accessor :guest_port
|
||||
attr_accessor :host
|
||||
attr_accessor :keep_alive
|
||||
attr_accessor :max_tries
|
||||
attr_accessor :port
|
||||
attr_accessor :private_key_path
|
||||
|
@ -19,6 +20,7 @@ module VagrantPlugins
|
|||
@forward_x11 = UNSET_VALUE
|
||||
@guest_port = UNSET_VALUE
|
||||
@host = UNSET_VALUE
|
||||
@keep_alive = UNSET_VALUE
|
||||
@max_tries = UNSET_VALUE
|
||||
@port = UNSET_VALUE
|
||||
@private_key_path = UNSET_VALUE
|
||||
|
@ -32,6 +34,7 @@ module VagrantPlugins
|
|||
@forward_x11 = false if @forward_x11 == UNSET_VALUE
|
||||
@guest_port = nil if @guest_port == UNSET_VALUE
|
||||
@host = nil if @host == UNSET_VALUE
|
||||
@keep_alive = false if @keep_alive == UNSET_VALUE
|
||||
@max_tries = nil if @max_tries == UNSET_VALUE
|
||||
@port = nil if @port == UNSET_VALUE
|
||||
@private_key_path = nil if @private_key_path == UNSET_VALUE
|
||||
|
|
Loading…
Reference in New Issue