Skip to content

Commit

Permalink
Merge branch 'fix-yandex-cloud#205'
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-j-mikhin committed Aug 9, 2023
2 parents cdbda6c + 32490ff commit 5bf87b7
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 5bf87b7

Please sign in to comment.