|
|
597952 |
From 4dde2a9bed58aba13c730bf4a7314b21038d7a31 Mon Sep 17 00:00:00 2001
|
|
|
597952 |
From: Eduardo Otubo <otubo@redhat.com>
|
|
|
597952 |
Date: Mon, 25 Jan 2021 16:24:29 +0100
|
|
|
597952 |
Subject: [PATCH 2/2] Revert "ssh_util: handle non-default AuthorizedKeysFile
|
|
|
597952 |
config (#586)" (#775)
|
|
|
597952 |
|
|
|
597952 |
RH-Author: Eduardo Terrell Ferrari Otubo (eterrell)
|
|
|
597952 |
RH-MergeRequest: 38: Revert "ssh_util: handle non-default AuthorizedKeysFile config (#586)" (#775)
|
|
|
597952 |
RH-Commit: [1/1] aec2860c773ad1921f3949dc622543e81860c5bf (eterrell/cloud-init)
|
|
|
597952 |
RH-Bugzilla: 1919972
|
|
|
597952 |
|
|
|
597952 |
commit cdc5b81f33aee0ed3ef1ae239e5cec1906d0178a
|
|
|
597952 |
Author: Daniel Watkins <oddbloke@ubuntu.com>
|
|
|
597952 |
Date: Tue Jan 19 12:23:23 2021 -0500
|
|
|
597952 |
|
|
|
597952 |
Revert "ssh_util: handle non-default AuthorizedKeysFile config (#586)" (#775)
|
|
|
597952 |
|
|
|
597952 |
This reverts commit b0e73814db4027dba0b7dc0282e295b7f653325c.
|
|
|
597952 |
|
|
|
597952 |
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
|
|
|
597952 |
---
|
|
|
597952 |
cloudinit/ssh_util.py | 6 +++---
|
|
|
597952 |
tests/unittests/test_sshutil.py | 6 +++---
|
|
|
597952 |
2 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
597952 |
|
|
|
597952 |
diff --git a/cloudinit/ssh_util.py b/cloudinit/ssh_util.py
|
|
|
597952 |
index d5113996..c08042d6 100644
|
|
|
597952 |
--- a/cloudinit/ssh_util.py
|
|
|
597952 |
+++ b/cloudinit/ssh_util.py
|
|
|
597952 |
@@ -262,13 +262,13 @@ def extract_authorized_keys(username, sshd_cfg_file=DEF_SSHD_CFG):
|
|
|
597952 |
|
|
|
597952 |
except (IOError, OSError):
|
|
|
597952 |
# Give up and use a default key filename
|
|
|
597952 |
- auth_key_fns.append(default_authorizedkeys_file)
|
|
|
597952 |
+ auth_key_fns[0] = default_authorizedkeys_file
|
|
|
597952 |
util.logexc(LOG, "Failed extracting 'AuthorizedKeysFile' in SSH "
|
|
|
597952 |
"config from %r, using 'AuthorizedKeysFile' file "
|
|
|
597952 |
"%r instead", DEF_SSHD_CFG, auth_key_fns[0])
|
|
|
597952 |
|
|
|
597952 |
- # always store all the keys in the first file configured on sshd_config
|
|
|
597952 |
- return (auth_key_fns[0], parse_authorized_keys(auth_key_fns))
|
|
|
597952 |
+ # always store all the keys in the user's private file
|
|
|
597952 |
+ return (default_authorizedkeys_file, parse_authorized_keys(auth_key_fns))
|
|
|
597952 |
|
|
|
597952 |
|
|
|
597952 |
def setup_user_keys(keys, username, options=None):
|
|
|
597952 |
diff --git a/tests/unittests/test_sshutil.py b/tests/unittests/test_sshutil.py
|
|
|
597952 |
index 88a111e3..fd1d1bac 100644
|
|
|
597952 |
--- a/tests/unittests/test_sshutil.py
|
|
|
597952 |
+++ b/tests/unittests/test_sshutil.py
|
|
|
597952 |
@@ -593,7 +593,7 @@ class TestMultipleSshAuthorizedKeysFile(test_helpers.CiTestCase):
|
|
|
597952 |
fpw.pw_name, sshd_config)
|
|
|
597952 |
content = ssh_util.update_authorized_keys(auth_key_entries, [])
|
|
|
597952 |
|
|
|
597952 |
- self.assertEqual(authorized_keys, auth_key_fn)
|
|
|
597952 |
+ self.assertEqual("%s/.ssh/authorized_keys" % fpw.pw_dir, auth_key_fn)
|
|
|
597952 |
self.assertTrue(VALID_CONTENT['rsa'] in content)
|
|
|
597952 |
self.assertTrue(VALID_CONTENT['dsa'] in content)
|
|
|
597952 |
|
|
|
597952 |
@@ -610,7 +610,7 @@ class TestMultipleSshAuthorizedKeysFile(test_helpers.CiTestCase):
|
|
|
597952 |
sshd_config = self.tmp_path('sshd_config')
|
|
|
597952 |
util.write_file(
|
|
|
597952 |
sshd_config,
|
|
|
597952 |
- "AuthorizedKeysFile %s %s" % (user_keys, authorized_keys)
|
|
|
597952 |
+ "AuthorizedKeysFile %s %s" % (authorized_keys, user_keys)
|
|
|
597952 |
)
|
|
|
597952 |
|
|
|
597952 |
(auth_key_fn, auth_key_entries) = ssh_util.extract_authorized_keys(
|
|
|
597952 |
@@ -618,7 +618,7 @@ class TestMultipleSshAuthorizedKeysFile(test_helpers.CiTestCase):
|
|
|
597952 |
)
|
|
|
597952 |
content = ssh_util.update_authorized_keys(auth_key_entries, [])
|
|
|
597952 |
|
|
|
597952 |
- self.assertEqual(user_keys, auth_key_fn)
|
|
|
597952 |
+ self.assertEqual("%s/.ssh/authorized_keys" % fpw.pw_dir, auth_key_fn)
|
|
|
597952 |
self.assertTrue(VALID_CONTENT['rsa'] in content)
|
|
|
597952 |
self.assertTrue(VALID_CONTENT['dsa'] in content)
|
|
|
597952 |
|
|
|
597952 |
--
|
|
|
597952 |
2.18.4
|
|
|
597952 |
|