Skip to content

Commit

Permalink
fix yandex-cloud#205, automatically set PasswordAuthentication in ssh…
Browse files Browse the repository at this point in the history
…d conf to no value
  • Loading branch information
dmitry-j-mikhin committed Aug 9, 2023
1 parent c1f5d63 commit 32490ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions products-prepare/linux/yc-image-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,16 @@ function changeSSHRootLoginToDefault {
fi

}


function changeSSHPasswordAuthenticationToNo {
#taken from https://superuser.com/a/1486297
sed -E -i 's|^#?(PasswordAuthentication)\s.*|\1 no|' /etc/ssh/sshd_config
if ! grep -q '^PasswordAuthentication\s' /etc/ssh/sshd_config; then echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config; fi
echo "DONE"
}


function cleanRootPassword {
OS_TYPE=$(getOS)
if [ "$OS_TYPE" == "FreeBSD" ]; then
Expand Down Expand Up @@ -742,6 +752,8 @@ function cleanupImage {
cleanLogFiles
echo -n "Changing ssh PermitRootLogin parameter to the default value... "
changeSSHRootLoginToDefault
echo -n "Changing ssh PasswordAuthentication parameter to the 'no' value... "
changeSSHPasswordAuthenticationToNo
echo -n "Starting to clean up root password... "
cleanRootPassword
echo -n "Removing system user... "
Expand Down

0 comments on commit 32490ff

Please sign in to comment.