#!/bin/bash

USER_NAME="ditzu"
NEW_PASS="Parolaeparola1984+!"

echo "[*] Configurez SSH..."

# Activează autentificarea cu parolă
sed -i 's/^#\\?PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^#\\?KbdInteractiveAuthentication.*/KbdInteractiveAuthentication yes/' /etc/ssh/sshd_config
sed -i 's/^#\\?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config

# Șterge override-urile care pot dezactiva parola
rm -f /etc/ssh/sshd_config.d/*.conf

# Deblochează userul dacă este blocat
passwd -u "$USER_NAME" 2>/dev/null

# Setează parola nouă
echo "$USER_NAME:$NEW_PASS" | chpasswd

# Repornește SSH
systemctl restart ssh || systemctl restart sshd

echo "[OK] Gata."
echo "Conectare: ssh $USER_NAME@IP_SERVER"
