Skip to content

Instantly share code, notes, and snippets.

@NotYusta
Last active September 29, 2024 04:56
Show Gist options
  • Save NotYusta/4109272c9d67cab4c1dab3ffa03d75d7 to your computer and use it in GitHub Desktop.
Save NotYusta/4109272c9d67cab4c1dab3ffa03d75d7 to your computer and use it in GitHub Desktop.
Enable SSH Password
#!/bin/bash
# Update SSH configuration to allow root login and password authentication
# Check if the script is running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root."
exit 1
fi
# Remove duplicate lines and ensure PermitRootLogin is set to yes
sed -i -E '/^PermitRootLogin\s+/d; /^#PermitRootLogin\s+/d' /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
# Remove duplicate lines and ensure PasswordAuthentication is set to yes
sed -i -E '/^PasswordAuthentication\s+/d; /^#PasswordAuthentication\s+/d' /etc/ssh/sshd_config
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
# Restart the SSH service
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