Enforce 0600 permissions on an existing SSH private key file.

Conflicts:
    tripleo_common/actions/ansible.py

Change-Id: If5d79f75037e252276a76bf010874e374df67e87
Closes-Bug: #1859244
Signed-off-by: Luke Short <ekultails@gmail.com>
(cherry picked from commit bbca58f2dd)
This commit is contained in:
Luke Short 2020-01-10 16:08:01 -05:00
parent bf969fe66a
commit 41cf8e84b3
1 changed files with 2 additions and 0 deletions

View File

@ -231,6 +231,7 @@ class AnsibleAction(actions.Action):
# NOTE(flaper87): if it's a path, use it
if (isinstance(self._ssh_private_key, six.string_types) and
os.path.exists(self._ssh_private_key)):
os.chmod(self._ssh_private_key, 0o600)
return self._ssh_private_key
path = os.path.join(self.work_dir, 'ssh_private_key')
@ -461,6 +462,7 @@ class AnsiblePlaybookAction(base.TripleOAction):
# NOTE(flaper87): if it's a path, use it
if (isinstance(self._ssh_private_key, six.string_types) and
os.path.exists(self._ssh_private_key)):
os.chmod(self._ssh_private_key, 0o600)
return self._ssh_private_key
path = os.path.join(self.work_dir, 'ssh_private_key')