This repository contains scripts designed to enable root login via SSH on a Linux server. The scripts update the SSH configuration to allow root login and password authentication, prompt the user to set the root password, restart the SSH service, and then delete themselves after successful execution.
- Bash (
enable_root.sh
): Original script written in Bash. - Python (
enable_root.py
): Python version of the script. - Node.js (
enable_root.js
): Node.js version of the script.
- PermitRootLogin: Enables
PermitRootLogin
in the SSH configuration to allow root login. - PasswordAuthentication: Enables
PasswordAuthentication
in the SSH configuration to allow password-based SSH access. - Root Password Setup: Prompts the user to set a new root password.
- Service Detection and Restart: Automatically detects and restarts the appropriate SSH service (
sshd
orssh
). - Self-Deletion: Deletes the script after successful execution to prevent unauthorized reuse.
- Error Handling: Comprehensive error handling is implemented in each script to ensure that any failures during the script execution are reported, and appropriate action is taken.
- Logging: The scripts log significant actions and errors to a log file for easier troubleshooting and audit trails.
- Supported Linux Distributions:
- CentOS
- Debian
- Ubuntu
- Fedora
- Arch Linux
- SUSE
- Other similar distributions
- Privileges:
- The script must be run with sudo or root privileges to modify SSH configurations and restart services.
-
Clone the Repository:
git clone https://github.com/ThunderDoesDev/Enable-Root-SSH-Access.git cd Enable-Root-SSH-Access
-
Make the Script Executable:
-
Bash:
chmod +x enable_root.sh
-
Python:
chmod +x enable_root.py
-
Node.js:
chmod +x enable_root.js
-
-
Run the Script:
sudo ./enable_root.sh
-
Script Execution:
- The script will modify the SSH configuration to allow root login and password authentication.
- You will be prompted to set a new root password.
- The script will automatically detect and restart the appropriate SSH service (
sshd
orssh
). - After successful execution, the script will delete itself.
- Error Handling: If any step fails (e.g., configuration update, service restart), the script will log the error and exit gracefully.
- Logging: Actions and errors are logged to
/var/log/ssh_config_update.log
for later review.
-
Install Python (if not already installed):
sudo apt-get install python3
-
Run the Script:
sudo ./enable_root.py
-
Script Execution:
- The script will modify the SSH configuration to allow root login and password authentication.
- You will be prompted to set a new root password.
- The script will automatically detect and restart the appropriate SSH service (
sshd
orssh
). - After successful execution, the script will delete itself.
- Error Handling: The Python script includes error handling that captures issues during execution, logs them, and exits with an appropriate error message.
- Logging: Actions and errors are logged to
/var/log/ssh_config_update.log
.
-
Install Node.js (if not already installed):
sudo apt-get install nodejs
-
Run the Script:
sudo ./enable_root.js
-
Script Execution:
- The script will modify the SSH configuration to allow root login and password authentication.
- You will be prompted to set a new root password.
- The script will automatically detect and restart the appropriate SSH service (
sshd
orssh
). - After successful execution, the script will delete itself.
- Error Handling: The Node.js script handles errors by logging any issues encountered during execution and exiting with a message.
- Logging: All actions and errors are logged to
/var/log/ssh_config_update.log
.
- Warning: Enabling root login via SSH is a significant security risk, especially in production environments. It is strongly recommended to disable root login after performing necessary administrative tasks.
- Post-Usage: Consider reverting the changes made by this script once you no longer need root SSH access to enhance server security.
-
Service Restart Issues: If the script fails to restart the SSH service, ensure that the correct SSH service is installed and running (
sshd
orssh
). You can check the service status using:sudo systemctl status sshd sudo systemctl status ssh
-
Configuration Check: Verify that the changes were applied correctly by inspecting the SSH configuration file at
/etc/ssh/sshd_config
. Ensure that the following lines are set:PermitRootLogin yes PasswordAuthentication yes
-
Log File Review: If the script fails or you encounter issues, check the log file at
/var/log/ssh_config_update.log
for detailed error messages and actions taken by the script.
This project is licensed under the APACHE License. See the LICENSE file for more details.
For support, issues, or enhancements, please open an issue in this repository or join our Discord support server.
Disclaimer: This script is provided "as is" without any warranties or guarantees. By using this script, you agree to take full responsibility for any security implications that may arise from enabling root login via SSH on your server.