From 92de2abeea611cb1ed98f0d493c0fabe91db1c9f Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 31 Jul 2019 00:13:50 +0100 Subject: [PATCH] issue #543: use key from Git, newer ssh-keygen unsupported by Paramiko --- .ci/localhost_ansible_tests.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.ci/localhost_ansible_tests.py b/.ci/localhost_ansible_tests.py index b795da48..662c7c73 100755 --- a/.ci/localhost_ansible_tests.py +++ b/.ci/localhost_ansible_tests.py @@ -3,6 +3,7 @@ import glob import os +import shutil import sys import ci_lib @@ -12,6 +13,7 @@ from ci_lib import run TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') IMAGE_PREP_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/image_prep') HOSTS_DIR = os.path.join(TESTS_DIR, 'hosts') +KEY_PATH = os.path.join(TESTS_DIR, '../data/docker/mitogen__has_sudo_pubkey.key') with ci_lib.Fold('unit_tests'): @@ -23,21 +25,17 @@ with ci_lib.Fold('job_setup'): # Don't set -U as that will upgrade Paramiko to a non-2.6 compatible version. run("pip install -q ansible==%s", ci_lib.ANSIBLE_VERSION) - os.chdir(TESTS_DIR) - os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7)) - + os.chmod(KEY_PATH, int('0600', 8)) if not ci_lib.exists_in_path('sshpass'): run("brew install http://git.io/sshpass.rb") with ci_lib.Fold('machine_prep'): key_path = os.path.expanduser('~/.ssh/id_rsa') - if not os.path.exists(key_path): - run("ssh-keygen -N '' -f %s", key_path) + shutil.copy(KEY_PATH, key_path) auth_path = os.path.expanduser('~/.ssh/authorized_keys') - with open(auth_path, 'a') as fp: - fp.write(open(key_path + '.pub').read()) + os.system('ssh-keygen -y -f %s >> %s' % (key_path, auth_path)) os.chmod(auth_path, int('0600', 8)) if os.path.expanduser('~mitogen__user1') == '~mitogen__user1':