feat: add support for alternate ssh authorized_keys locations

On Ubuntu within AWS environments, the default user is the `ubuntu` user, and this is where the ssh key should be pulled from. CentOS has a tendency to use `ec2-user`.

On all other environments, the `root` user is typically the only user provisioned.

Closes #3372
This commit is contained in:
Jose Diaz-Gonzalez committed 2019-01-06 22:26:54 -05:00
1 parent 85bf4dd5cd
commit f8766708c7
1 file changed
+7 -1
+7 -1
View File
@@ -21,7 +21,13 @@ try:
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
pass pass
key_file = os.getenv('KEY_FILE', '/root/.ssh/authorized_keys') key_file = os.getenv('KEY_FILE', None)
if os.path.isfile('/home/ec2-user/.ssh/authorized_keys'):
key_file = '/home/ec2-user/.ssh/authorized_keys'
elif os.path.isfile('/home/ubuntu/.ssh/authorized_keys'):
key_file = '/home/ubuntu/.ssh/authorized_keys'
else:
key_file = '/root/.ssh/authorized_keys'
admin_keys = [] admin_keys = []
if os.path.isfile(key_file): if os.path.isfile(key_file):