Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Created June 3, 2025 12:44
Show Gist options
  • Save NotYusta/94564b3fd98fd3a95a67d07277b2746e to your computer and use it in GitHub Desktop.
Save NotYusta/94564b3fd98fd3a95a67d07277b2746e to your computer and use it in GitHub Desktop.
Enable Password SSH
#!/bin/bash
# Update SSH configuration to allow root login and password authentication
# Ensure running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root."
exit 1
fi
# Backup sshd_config before modifying
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%T)
# Remove any existing PermitRootLogin lines (commented or not)
sed -i '/^\s*#\?\s*PermitRootLogin\s\+/d' /etc/ssh/sshd_config
# Add PermitRootLogin yes
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
# Remove any existing PasswordAuthentication lines (commented or not)
sed -i '/^\s*#\?\s*PasswordAuthentication\s\+/d' /etc/ssh/sshd_config
# Add PasswordAuthentication yes
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
# Restart sshd
systemctl restart sshd
echo "SSH configuration updated: PermitRootLogin and PasswordAuthentication set to yes."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment