From: Kyr Shatskyy Date: Sat, 5 Sep 2020 09:23:56 +0000 (+0200) Subject: task/ssh_keys: use remote.write_file instead misc.create_file X-Git-Tag: 1.1.0~47^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1557%2Fhead;p=teuthology.git task/ssh_keys: use remote.write_file instead misc.create_file Because misc.create_file with data arguments creates file, changes permissions, and later appends the data using misc.append_lines_to_file, this logic makes the algorythm above to fail if the file created without write permissions. 2020-09-05T10:00:32.003 INFO:teuthology.task.ssh_keys:pushing keys to smithi086.front.sepia.ceph.com for ubuntu 2020-09-05T10:00:32.003 INFO:teuthology.orchestra.run.smithi086:> rm -f -- /home/ubuntu/.ssh/id_rsa 2020-09-05T10:00:32.046 INFO:teuthology.orchestra.run.smithi086:> touch /home/ubuntu/.ssh/id_rsa && chmod 500 -- /home/ubuntu/.ssh/id_rsa 2020-09-05T10:00:32.095 INFO:teuthology.orchestra.run.smithi086:> set -ex 2020-09-05T10:00:32.096 INFO:teuthology.orchestra.run.smithi086:> dd of=/home/ubuntu/.ssh/id_rsa conv=notrunc oflag=append 2020-09-05T10:00:32.140 INFO:teuthology.orchestra.run.smithi086.stderr:+ dd of=/home/ubuntu/.ssh/id_rsa conv=notrunc oflag=append 2020-09-05T10:00:32.142 INFO:teuthology.orchestra.run.smithi086.stderr:dd: failed to open '/home/ubuntu/.ssh/id_rsa': Permission denied 2020-09-05T10:00:32.142 DEBUG:teuthology.orchestra.run:got remote process result: 1 However we have more advanced remote.write_file function now, which does not have such issues and moreover creates file with the data provided in a single hop without trying to download the file locally. Related-to: 243ff3bbf218102b24ed992e3931bf8c76cdaadd Related-to: 45aba9cf8d72fd30ca607200694c638cfd240fd8 Signed-off-by: Kyr Shatskyy --- diff --git a/teuthology/task/ssh_keys.py b/teuthology/task/ssh_keys.py index a38ed9406..f7e0dba32 100644 --- a/teuthology/task/ssh_keys.py +++ b/teuthology/task/ssh_keys.py @@ -154,13 +154,13 @@ def push_keys_to_host(ctx, config, public_key, private_key): priv_key_data = '{priv_key}'.format(priv_key=private_key) misc.delete_file(remote, priv_key_file, force=True) # Hadoop requires that .ssh/id_rsa have permissions of '500' - misc.create_file(remote, priv_key_file, priv_key_data, str(500)) + remote.write_file(priv_key_file, priv_key_data, mode='0500') # then a private key pub_key_file = '/home/{user}/.ssh/id_rsa.pub'.format(user=username) pub_key_data = 'ssh-rsa {pub_key} {user_host}'.format(pub_key=public_key, user_host=str(remote)) misc.delete_file(remote, pub_key_file, force=True) - misc.create_file(remote, pub_key_file, pub_key_data) + remote.write_file(pub_key_file, pub_key_data) # add appropriate entries to the authorized_keys file for this host auth_keys_file = '/home/{user}/.ssh/authorized_keys'.format(