From f8766708c7511a7b5318e634ff9cadecb74e8871 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sun, 6 Jan 2019 22:26:54 -0500 Subject: [PATCH] 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 --- contrib/dokku-installer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/dokku-installer.py b/contrib/dokku-installer.py index 5b321c98d..7c31b2887 100755 --- a/contrib/dokku-installer.py +++ b/contrib/dokku-installer.py @@ -21,7 +21,13 @@ try: except subprocess.CalledProcessError: 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 = [] if os.path.isfile(key_file):