Last active
September 29, 2024 04:56
-
-
Save NotYusta/4109272c9d67cab4c1dab3ffa03d75d7 to your computer and use it in GitHub Desktop.
Enable SSH Password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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