Skip to content

Commit

Permalink
Use cloud config instead of bash script.
Browse files Browse the repository at this point in the history
To set ssh key and confirm root login disabled.
  • Loading branch information
smarlowucf committed Apr 1, 2021
1 parent 3bd9a45 commit f0b381d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions img_proof/ipa_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
IPA_HISTORY_FILE = os.path.join(HOME, '.config', 'img_proof', '.history')
IPA_RESULTS_PATH = os.path.join(HOME, 'img_proof', 'results')

BASH_SSH_SCRIPT = '''#!/bin/bash
echo {key} >> /home/{user}/.ssh/authorized_keys
BASH_SSH_SCRIPT = '''#cloud-config
disable_root: true
runcmd:
- [ sh, -c, 'echo {key} >> /home/{user}/.ssh/authorized_keys' ]
'''

SYNC_POINTS = (
Expand Down
7 changes: 5 additions & 2 deletions tests/test_ipa_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,11 @@ def test_cloud_get_user_data(self, mock_get_ssh_key):
result = provider._get_user_data()

assert result == \
'#!/bin/bash\n' \
'echo testkey12345 >> /home/ec2-user/.ssh/authorized_keys\n'
"#cloud-config\n" \
"disable_root: true\n\n" \
"runcmd:\n" \
" - [ sh, -c, 'echo testkey12345 >> " \
"/home/ec2-user/.ssh/authorized_keys' ]\n"

def test_cloud_get_non_null_values(self):
"""Test cloud get non null values method."""
Expand Down

0 comments on commit f0b381d

Please sign in to comment.