A simple bash script to enable SSH root login with a password on Ubuntu servers. This script modifies SSH configuration and sets a root password, allowing secure root access via SSH.
- Enables SSH root login with a password.
- Prompts user to set a custom root password.
- Automatically updates SSH configuration.
- Compatible with cloud-init SSH configuration (
60-cloudimg-settings.conf).
- Connect to your server:
Ensure you are connected to your server as a user with sudo privileges.
- Run the Script:
Execute the script directly from the repository:
bash <(curl -Ls https://raw.githubusercontent.com/DrSaeedHub/RootSet/main/enable-root-login.sh)- Follow the Prompts:
- Enter the new root password when prompted.
- Confirm the root password.
- The script will automatically restart the SSH service and apply the changes.
- This script modifies the SSH configuration to allow root login with a password.
- It is recommended to disable root login after performing necessary operations for better security:
nano /etc/ssh/sshd_configSet the following values:
PermitRootLogin no
PasswordAuthentication no
Restart the SSH service:
sudo systemctl restart sshdenable-root-login.sh- Main script to enable root login.
-
If you encounter
Permission denied (publickey)after running the script, ensure that SSH service is properly restarted:sudo systemctl restart sshd
-
Verify the SSH configuration:
sudo sshd -t
Feel free to fork the repository, make improvements, and submit a pull request. Contributions are welcome!
Created by DrSaeedHub.