#!/bin/bash

# Clear the screen
clear

# Add a delay function for better human-readable output
delay() {
    sleep 2
}

# Color definitions
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No color

# Step 1: Modify the sshd_config file
echo -e "${YELLOW}Modifying /etc/ssh/sshd_config to allow root SSH access...${NC}"
delay

# Edit the file using sed: remove the comment (#) and change "prohibit-password" to "yes"
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config

echo -e "${GREEN}sshd_config modified successfully!${NC}"
delay

# Step 2: Reload sshd service to apply changes
echo -e "${YELLOW}Reloading sshd service to apply changes...${NC}"
delay

systemctl restart sshd

echo -e "${GREEN}sshd service reloaded successfully!${NC}"
delay

# Step 3: Final message
echo -e "${GREEN}All done! Root SSH access has been enabled.${NC}"
