The secure-ssh-setup.sh
script is designed to automate the process of securing an SSH server by performing the following tasks:
- Adding a new user with a specified username and password.
- Adding the new user to the appropriate sudo group based on the operating system.
- Updating the SSH configuration file with security enhancements.
- Restarting the SSH service to apply the changes.
- Adds a new user and sets their password.
- Adds the user to the
sudo
group (Debian/Ubuntu) orwheel
group (CentOS/RHEL/Fedora). - Updates SSH configuration settings:
ClientAliveInterval
ClientAliveCountMax
PermitEmptyPasswords
Protocol
Port
- Restarts the SSH service to apply the new settings.
- Provides detailed logging for each step.
- A Linux-based system (Debian, Ubuntu, CentOS, RHEL, Fedora).
- Root or sudo access to run the script.
-
Download the Script:
Clone the repository or download the
secure-ssh-setup.sh
script to your local machine.git clone https://github.com/PKHarsimran/PiSecure-SSH.git cd PiSecure-SSH/scripts
-
Modify the Script:
Open the script and update the USERNAME and PASSWORD variables with your desired values.
USERNAME="newuser" PASSWORD="password"
-
Run the Script:
Execute the script with root or sudo privileges.
sudo bash secure-ssh-setup.sh
The script provides detailed logging at each step to ensure that users are informed of the progress and any potential issues.