Skip to content

Commit 42afe88

Browse files
committed
base.py: Workaround ssh hangs on Windows
Workaround for ssh hangs sometimes when executing command remotely on Windows (PowerShell/Win32-OpenSSH#1334). It may hit an SSH rate limiter on the server-side network, which will block IP addresses that have too many ssh connection requests within a short period of time.
1 parent 16fdc94 commit 42afe88

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

base.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,11 @@ def get_backup_dir(backup_dir, rev):
10911091
Util.error('Could not find backup %s' % rev)
10921092

10931093
@staticmethod
1094-
def remotify_cmd(server, cmd, extra_arg=''):
1095-
new_cmd = 'ssh wp@%s' % server
1094+
def remotify_cmd(server, cmd, disable_x11_fw=False, extra_arg=''):
1095+
new_cmd = 'ssh'
1096+
if disable_x11_fw:
1097+
new_cmd += ' -x'
1098+
new_cmd += ' wp@%s' % server
10961099
if extra_arg:
10971100
new_cmd += ' %s' % extra_arg
10981101
new_cmd += ' "%s"' % cmd
@@ -1101,7 +1104,9 @@ def remotify_cmd(server, cmd, extra_arg=''):
11011104
@staticmethod
11021105
def check_server_backup(relative_path, rev_file):
11031106
cmd = 'ls %s/%s/%s/%s' % (Util.LINUX_BACKUP_DIR, Util.HOST_OS, relative_path, rev_file)
1104-
cmd = Util.remotify_cmd(Util.BACKUP_SERVER, cmd)
1107+
# Disable SSH X11 forwarding on Windows to workaround SSH hangs when executing command remotely.
1108+
# Issue: https://github.com/PowerShell/Win32-OpenSSH/issues/1334
1109+
cmd = Util.remotify_cmd(Util.BACKUP_SERVER, cmd, disable_x11_fw=Util.HOST_OS == Util.WINDOWS)
11051110
ret, _ = Util.execute(cmd, exit_on_error=False)
11061111
if ret:
11071112
return False

0 commit comments

Comments
 (0)