From 545567829723980d282c06ee80152152e89c4909 Mon Sep 17 00:00:00 2001 From: Liraz Siri Date: Wed, 2 Sep 2026 18:39:43 +0000 Subject: [PATCH] Avoid CloudTasks SSH setup hangs Pass the temporary authorized key in the remote command instead of streaming it through the SSH process standard input. Multiprocess workers can inherit the input pipe and prevent EOF, leaving the remote cat process blocked until the 120-second setup timeout. This keeps key installation shell-quoted and removes the inherited-descriptor dependency. Verified with Python 2 compilation and a live copy/remove cycle against the existing v19 converter. --- cloudtask/ssh.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cloudtask/ssh.py b/cloudtask/ssh.py index cf50bbc..288b8f3 100644 --- a/cloudtask/ssh.py +++ b/cloudtask/ssh.py @@ -16,6 +16,7 @@ from temp import TempFile import executil import hashlib +from pipes import quote class PrivateKey: class Error(Exception): @@ -134,12 +135,11 @@ def copy_id(self, key): if not isinstance(key, PrivateKey): key = PrivateKey(key) - command = 'mkdir -p $HOME/.ssh; cat >> $HOME/.ssh/authorized_keys' + authorized_key = "%s %s" % (key.public, key.fingerprint) + command = ("mkdir -p $HOME/.ssh; printf '%%s\\n' %s " + ">> $HOME/.ssh/authorized_keys") % quote(authorized_key) command = self.command(command) - command.tochild.write("%s %s\n" % (key.public, key.fingerprint)) - command.tochild.close() - try: command.close() except command.Error, e: