Commit Graph

85 Commits

Author SHA1 Message Date
Pratik Tripathy
88f8a98bda LICENSE 2025-10-14 21:18:16 +05:30
Pratik Tripathy
6cf74651bb chore(readme): Retrospect 2025-10-14 17:24:23 +05:30
Pratik Tripathy
d7581997de fix: Remove SSH files after the operation completion 2025-10-14 17:23:37 +05:30
Pratik Tripathy
3ff7ab52c9 feat: Support for Alma, Rocky, CentOS, openSUSE
- Update & upgrade packages before installing
- Alma, Rocky, CentOS: Install `epel-release` package
- Debian 12: Install `python3-systemd` package
- openSUSE: Enable `USERGROUPS_ENAB` in `/etc/login.defs` so groups gets
  auto-created for new users
- fix: Capture unrecognized OS as failure
2025-10-14 17:17:27 +05:30
Pratik Tripathy
da8b830534 fix(fail2ban): Multiple fixes
- fix: quotes removed from `emptylog` in jail.local
- refactor: Remove separate fn for Linux fail2ban
- fix: Check fail2ban config validity before starting the service
- fix: FreeBSD: enable fail2ban before starting the service
2025-10-13 13:35:03 +05:30
Pratik Tripathy
2e1046d801 fix(pf-FreeBSD): Enable pf before starting the service 2025-10-13 12:15:43 +05:30
Pratik Tripathy
18a8012e47 fix(sudo): For wheel group as sudoer, check and creates the sudoers
directory & file
2025-10-13 12:08:00 +05:30
Pratik Tripathy
40be32107e refactor: Use systemctl as the 1st check as service manager command 2025-10-13 12:06:43 +05:30
Pratik Tripathy
72b6d41cc0 feat: Make username mandatory option
- Script runs on a new server; must provide a username
2025-10-13 12:03:09 +05:30
Pratik Tripathy
0a1adb5ca1 feat(sshd): Use modern sshd drop-in configuration directory
- Create `/etc/ssh/sshd_config.d` if it does not exists
- Add hardening configurations to
  `/etc/ssh/sshd_config.d/99-hardening.conf`
2025-10-12 00:24:02 +05:30
Pratik Tripathy
6e5f3c1be5 fix(fail2ban): Use https protocol to get the server IP 2025-10-11 19:42:22 +05:30
Pratik Tripathy
dcb2b4c340 chore: Consistent heredoc delimiter name 2025-10-11 19:41:26 +05:30
Pratik Tripathy
a1d6b4a669 fix(sshd): Check ssh configuration sanity before restarting sshd service 2025-10-11 19:37:17 +05:30
Pratik Tripathy
a5b0838fb3 chore(readme): Even more precise description 2025-10-11 19:34:57 +05:30
Pratik Tripathy
d92b0284a5 feat: Readme updated
- Added short link to down
- Removed Dockerfile: can't test the script with them. Use KVM instead.
- AI word salads removed
2025-10-10 23:40:54 +05:30
Pratik Tripathy
959a4b739e fix(FreeBSD pf): Avoid config file overwriting during fail2ban setup
- During fail2ban setup, `cp` `/etc/pf.conf` instead of `mv`
- Append fail2ban configuration to `/etc/pf.conf`
2025-10-10 22:11:21 +05:30
Pratik Tripathy
b2359227ee chore: Usage text updated 2025-10-09 23:39:53 +05:30
Pratik Tripathy
9cd038c228 feat: Don't store credentials in log file
- Display the credentials on console
- Removed option to hide credentials on console
- Log file in `/var/log` and not in current directory
- Remove SSH private key after displaying its on console
2025-10-09 23:38:38 +05:30
Pratik Tripathy
202ef6a648 feat(firewalld,freebds+fail2ban):
- Linux: ufw -> firewalld
- installations: separate install list for linux & freebsd
- firewall: `pf` for freebsd & `firewalld` for linux
- firewall: allow ssh, http, https in; block all other
- firewall freebsd: start pf & pflog services
- fail2ban: Jails for: ssh, nginx-botsearch, nginx-http-auth,
  nginx-limit-req, haproxy-http-auth, recidive
- fail2ban linux: action performed by `firewalld`
- fail2ban freebsd: action performed by `pf`
- chore: Hide command outputs from `if` conditions
- refactor: `if` with `else` checks positive conditions
- refactor: No explicit `return`s on success
- refactor: No `exit`s
- chore: Consistent log formatting with values inside `[]`
- fix: Reverting success isn't operation succes
2025-10-09 22:40:33 +05:30
Pratik Tripathy
4030f25ba9 chore: Messed up git stuff brought back 2025-09-08 17:46:36 +05:30
Pratik Tripathy
784dcfefcb feat: FreeBSD, Fedora, SUSE, Arch support for "Package installation"
operation

- List of packages to install maintained inside the method itself
- Debian/Ubuntu: Set timezone to UTC to not let apt blocked for response
2025-09-08 17:07:48 +05:30
Pratik Tripathy
8fbed3d811 feat: FreeBSD support for "SSH hardening" operation
- POSIX compliant usage of `sed` with `-i.tmp` for FreeBSD
- Reverting on error, moved to its own method
- refactor: Better variable names
- chore: Better logging; begin, success, failure
2025-09-08 16:49:43 +05:30
Pratik Tripathy
9590130d06 feat: FreeBSD support for "SSH Key Generation" operation 2025-09-08 16:05:57 +05:30
Pratik Tripathy
178cffcc67 feat: FreeBSD, Fedora, SUSE, Arch support for "Create new user"
operation

- Split "User creation" & "Granting new user sudo" into separate methods
- new: Abort on user creation failure
- new: Abort on sudo privilege failure
- Removed user existence check; it is done during argument parsing
- Consistent console & file logs; start, success & failure
- FreeBSD, Fedora, SUSE: Add `wheel` group to sudoer & add user to
  `wheel` group
- Debian, Ubuntu: Add user to `sudo` group
2025-09-08 15:50:12 +05:30
Pratik Tripathy
65a4d7ae98 feat: FreeBSD support for "root password reset" operation
- refactor: Operation logs moved from `main` to `reset_root_password`
- Always file-log command `output` and not only on operation error
2025-09-08 15:36:29 +05:30
Pratik Tripathy
3ad7fe9bff refactor: Better names & typo fixes
- `LOGFILE_NAME` -> `LOG_FILE_NAME`
- `create_logfile` -> `create_log_file`
- `print_logfile_details` -> `print_log_file_details`
- typo: `print_opration_details` -> `print_operation_details`
2025-09-08 15:31:33 +05:30
Pratik Tripathy
8948bd70a0 feat: Show everything that will be done before proceeding 2025-09-04 23:36:08 +05:30
Pratik Tripathy
389712283e Option to quit, log-level in file logs, fixes, refactors
- feat: Add log-level to file logs
- refactor: Calculate duration inside `formatted_execution_duration`
- refactor: Console log display `OK` -> `DONE`
- fix: Debian/Ubuntu: Set default TZ -> UTC to let the installation
continue without getting stuck
- fix: Use local variable to store `JAIL_LOCAL_FILE` in
`update_fail2ban_jail_local_file`
- feat: Give user option to quit before starting the script
2025-09-04 22:56:27 +05:30
Pratik Tripathy
142483196e refactor: Script name change, better fn name, fewer comments
- Script name internally changed to `linux-init-harden` -> `server-init-harden`
- Removed unnecessary comments
- Better function names explaining when they do
2025-09-04 16:36:43 +05:30
Pratik Tripathy
2f2d4142d4 chore(docs): refine project description for clarity and accuracy & remove old files 2024-12-21 19:53:41 +05:30
Pratik Tripathy
534b2f50a6 chore: Remove old screencaptures 2024-12-21 17:14:52 +05:30
Pratik Tripathy
22d6c03047 docs: reorganize and improve documentation
- Add SSH key management warnings and instructions
- Reorganize features and usage sections
- Update examples with consistent usernames
- Add post-installation steps
- Improve formatting and readability

chore(dockerfile): cleanup dockerfile formatting

- Remove extra newlines
- Consolidate package installation commands
- Update test command examples
2024-12-21 17:09:52 +05:30
Pratik Tripathy
e58d7058d4 feat: Redo major portion of the script
- Console log format simplified: OK, FAIL, WARN, INFO with colors
- Log file to contain everything else with timestamp
- User creation optional and only happens when -u <username> is provided
- SSH config: PubkeyAuthentication setting added
- Script now supports: debian, ubuntu, fedora & freebsd
- Service management fallbacks: service, systemctl, init.d
- UFW: enable ssh, http, https
- Fail2ban: WIP

feat(test): Docker file to test across all active debian, ubuntu & fedora dist

refactor(script): improve code organization and logging

- Group functions into helper and operations sections
- Order operations chronologically
- Enhance console log formatting and messages
- Update usage examples and comments
- Improve error handling and output logging
- Use darker color for credentials output for security
- Add shellcheck disable comments where necessary
2024-12-21 17:09:52 +05:30
Pratik Tripathy
1b1ab6379d feat(docker): Test script using docker
- README updated with docker instructions
2024-12-17 22:38:34 +05:30
Pratik Tripathy
40deeaac17 feat: Create new user
- Log stuff to a file and to console
- Create user
- Username from parameter if provided else generate it
- Revert user creation if it failed midway
2024-12-17 22:36:30 +05:30
Pratik Tripathy
657d6c0868 - Updated shebang for modern OSes - #!/bin/bash instead of #!/etc/bin/env bash
- For unsupported OSes to be able to show error message, 2 functions must be defined before usage
- Line breaks added to sources.list file
2021-10-27 01:49:25 +05:30
Pratik Tripathy
0c6cb0512c - Fail when apt-get not found on OS
- Generic method to find out os version code name
- Let user decide if they want to continue on a older/newer OS version
2021-10-27 00:35:54 +05:30
Pratik Kumar Tripathy
fea2d0e18a Update README.md
Added support for Ubuntu 20.04
2020-07-07 10:07:31 +05:30
Pratik Kumar Tripathy
f2b2c526db Added support for Ubuntu 20.04 2020-07-07 10:04:12 +05:30
Pratik
b6978b7266 shortened the script URL 2020-01-25 00:12:08 +05:30
Pratik Kumar Tripathy
57550ac62d Merge pull request #1 from rmclellan/master
Added Debian 10 Support
2019-09-09 22:59:23 +00:00
rmclellan
2d0c5f6b35 Added Debian 10 Support 2019-08-13 11:40:36 -07:00
Pratik
abd0a42d11 Readme
- Added license
- Sane defaults in the example
- Marked stable

Script
- Bumped the version to 1.0
- Fixed bug - While reverting user creation revert always  fails - was an issue with reseting the exit code
- Bugfix - Does not show all operation succeed when schedule apt download was not executed
- Prettier recap
2019-02-14 05:25:05 +05:30
Pratik
9e2dfc4bd1 Added only-create-user flag to stop execution after creating the user
Display script execution duration
2019-02-14 03:46:18 +05:30
Pratik
914ac35cb2 Script
- Logs updated
- root password change made possible from non-root user

Readme
- Added Screenshots
- Added FAQ section with - Non-Idempotency explained, rerun consequences expained, Listed all files that script edits and creates, Explained how to execute as non-root user
- Examples refined
- Informed that no software is even uninstalled
-
2019-02-13 22:57:10 +05:30
Pratik
0aa7b9e3b6 name changed 2019-02-13 22:47:18 +05:30
Pratik
1e7133e0be Added screencaptures 2019-02-13 22:42:06 +05:30
Pratik
f96590a3d4 Usage display text alignments 2019-02-13 07:11:05 +05:30
Pratik
76d3724af2 Added exit-code to file log
Updated read me for -hide flag
2019-02-13 07:07:21 +05:30
Pratik
17c4e244fa More missed renames + some more refactoring 2019-02-13 06:46:19 +05:30