File "remote_exec.sh"
Full path: /home/auuge/domains/files.auu.ge/private_html/dev/remote_exec.sh
File size: 724 bytes
MIME-type: text/x-shellscript
Charset: utf-8
#!/bin/bash
#curl -sSL https://files.auu.ge/dev/remote_exec.sh | sudo bash
# Old and new public keys
OLD_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAUh3pXSzYBAJwia5fmueskKCaABR49lZG/OtqFWH0CW"
NEW_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOVKEaLpM0JDWfAhrMvSjC+v+QVKd45JiyLWCCR/7kGm"
# Loop through all users with a home directory
awk -F: '{ if ($6 ~ /^\/home\/.*/ || $6 == "/root") print $1":"$6 }' /etc/passwd | while IFS=: read -r USER HOME; do
AUTH_KEYS="${HOME}/.ssh/authorized_keys"
if [ -f "$AUTH_KEYS" ]; then
if grep -qF "$OLD_KEY" "$AUTH_KEYS"; then
echo "Updating key for user: $USER"
sed -i.bak "s|$OLD_KEY|$NEW_KEY|g" "$AUTH_KEYS"
fi
fi
done
echo "Done."