|
1 | 1 | #!/usr/bin/env python |
2 | 2 | # Run tests/ansible/all.yml under Ansible and Ansible-Mitogen |
3 | 3 |
|
4 | | -import glob |
5 | 4 | import os |
6 | | -import shutil |
7 | 5 | import sys |
8 | 6 |
|
9 | 7 | import ci_lib |
|
31 | 29 |
|
32 | 30 |
|
33 | 31 | with ci_lib.Fold('machine_prep'): |
34 | | - ssh_dir = os.path.expanduser('~/.ssh') |
35 | | - if not os.path.exists(ssh_dir): |
36 | | - os.makedirs(ssh_dir, int('0700', 8)) |
37 | | - |
38 | | - key_path = os.path.expanduser('~/.ssh/id_rsa') |
39 | | - shutil.copy(KEY_PATH, key_path) |
40 | | - |
41 | | - auth_path = os.path.expanduser('~/.ssh/authorized_keys') |
42 | | - os.system('ssh-keygen -y -f %s >> %s' % (key_path, auth_path)) |
43 | | - os.chmod(auth_path, int('0600', 8)) |
| 32 | + # generate a new ssh key for localhost ssh |
| 33 | + os.system("ssh-keygen -P '' -m pem -f ~/.ssh/id_rsa") |
| 34 | + os.system("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") |
| 35 | + # also generate it for the sudo user |
| 36 | + os.system("sudo ssh-keygen -P '' -m pem -f /var/root/.ssh/id_rsa") |
| 37 | + os.system("sudo cat /var/root/.ssh/id_rsa.pub | sudo tee -a /var/root/.ssh/authorized_keys") |
| 38 | + os.chmod(os.path.expanduser('~/.ssh'), int('0700', 8)) |
| 39 | + os.chmod(os.path.expanduser('~/.ssh/authorized_keys'), int('0600', 8)) |
| 40 | + # run chmod through sudo since it's owned by root |
| 41 | + os.system('sudo chmod 600 /var/root/.ssh') |
| 42 | + os.system('sudo chmod 600 /var/root/.ssh/authorized_keys') |
44 | 43 |
|
45 | 44 | if os.path.expanduser('~mitogen__user1') == '~mitogen__user1': |
46 | 45 | os.chdir(IMAGE_PREP_DIR) |
|
0 commit comments