Keep SSH authorized keys in ansible-test setup.

pull/66878/head
Matt Clay 5 years ago
parent efd2dd8929
commit 428aaf7e65

@ -0,0 +1,2 @@
bugfixes:
- ansible-test now preserves existing SSH authorized keys when provisioning a remote host

@ -90,7 +90,8 @@ if [ ! -f "${HOME}/.ssh/id_rsa.pub" ]; then
chmod 0600 "${HOME}/.ssh/id_rsa.new"
sed 's/\(BEGIN\|END\) PRIVATE KEY/\1 RSA PRIVATE KEY/' "${HOME}/.ssh/id_rsa" > "${HOME}/.ssh/id_rsa.new"
mv "${HOME}/.ssh/id_rsa.new" "${HOME}/.ssh/id_rsa"
cp "${HOME}/.ssh/id_rsa.pub" "${HOME}/.ssh/authorized_keys"
cat "${HOME}/.ssh/id_rsa.pub" >> "${HOME}/.ssh/authorized_keys"
chmod 0600 "${HOME}/.ssh/authorized_keys"
for key in /etc/ssh/ssh_host_*_key.pub; do
pk=$(cat "${key}")
echo "localhost ${pk}" >> "${HOME}/.ssh/known_hosts"

Loading…
Cancel
Save