diff -Nru cloud-init-20.4/cloudinit/ssh_util.py cloud-init-20.4.1/cloudinit/ssh_util.py --- cloud-init-20.4/cloudinit/ssh_util.py 2020-11-24 17:38:50.000000000 +0000 +++ cloud-init-20.4.1/cloudinit/ssh_util.py 2021-01-15 15:53:27.000000000 +0000 @@ -262,13 +262,13 @@ except (IOError, OSError): # Give up and use a default key filename - auth_key_fns.append(default_authorizedkeys_file) + auth_key_fns[0] = default_authorizedkeys_file util.logexc(LOG, "Failed extracting 'AuthorizedKeysFile' in SSH " "config from %r, using 'AuthorizedKeysFile' file " "%r instead", DEF_SSHD_CFG, auth_key_fns[0]) - # always store all the keys in the first file configured on sshd_config - return (auth_key_fns[0], parse_authorized_keys(auth_key_fns)) + # always store all the keys in the user's private file + return (default_authorizedkeys_file, parse_authorized_keys(auth_key_fns)) def setup_user_keys(keys, username, options=None): diff -Nru cloud-init-20.4/debian/changelog cloud-init-20.4.1/debian/changelog --- cloud-init-20.4/debian/changelog 2021-01-11 22:31:19.000000000 +0000 +++ cloud-init-20.4.1/debian/changelog 2021-01-18 15:55:29.000000000 +0000 @@ -1,3 +1,11 @@ +cloud-init (20.4.1-0ubuntu1~18.04.1) bionic; urgency=medium + + * New upstream release. (LP: #1911680) + - Release 20.4.1 + - Revert "ssh_util: handle non-default AuthorizedKeysFile config (#586)" + + -- Daniel Watkins Mon, 18 Jan 2021 10:55:29 -0500 + cloud-init (20.4-0ubuntu1~18.04.2) bionic; urgency=medium * cherry-pick 4f62ae8d: Fix regression with handling of IMDS ssh keys diff -Nru cloud-init-20.4/tests/unittests/test_sshutil.py cloud-init-20.4.1/tests/unittests/test_sshutil.py --- cloud-init-20.4/tests/unittests/test_sshutil.py 2020-11-24 17:38:50.000000000 +0000 +++ cloud-init-20.4.1/tests/unittests/test_sshutil.py 2021-01-15 15:53:27.000000000 +0000 @@ -593,7 +593,7 @@ fpw.pw_name, sshd_config) content = ssh_util.update_authorized_keys(auth_key_entries, []) - self.assertEqual(authorized_keys, auth_key_fn) + self.assertEqual("%s/.ssh/authorized_keys" % fpw.pw_dir, auth_key_fn) self.assertTrue(VALID_CONTENT['rsa'] in content) self.assertTrue(VALID_CONTENT['dsa'] in content) @@ -610,7 +610,7 @@ sshd_config = self.tmp_path('sshd_config') util.write_file( sshd_config, - "AuthorizedKeysFile %s %s" % (user_keys, authorized_keys) + "AuthorizedKeysFile %s %s" % (authorized_keys, user_keys) ) (auth_key_fn, auth_key_entries) = ssh_util.extract_authorized_keys( @@ -618,7 +618,7 @@ ) content = ssh_util.update_authorized_keys(auth_key_entries, []) - self.assertEqual(user_keys, auth_key_fn) + self.assertEqual("%s/.ssh/authorized_keys" % fpw.pw_dir, auth_key_fn) self.assertTrue(VALID_CONTENT['rsa'] in content) self.assertTrue(VALID_CONTENT['dsa'] in content)