Commit Graph

40 Commits

Author SHA1 Message Date
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
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
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
f2b2c526db Added support for Ubuntu 20.04 2020-07-07 10:04:12 +05:30
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
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
Pratik
fe6872951d get_step_status function rectification 2019-02-13 06:01:20 +05:30
Pratik
be57c15186 Refactored to achieve the Better readability
- Renamed function names to be more consistent
- Renamed function names to mean what thet do
- Renamed variables to mean what they do

The op_code variable was confusing and would have created bugs
- Refined use of op_code and exit_code

- Need full tests to be done all over again
2019-02-13 05:15:50 +05:30
Pratik
70be73c547 Refactoring 2019-02-12 22:52:50 +05:30
Pratik
14154db5dc Added option (-hide) to hide credentials from screen 2019-02-11 22:13:58 +05:30
Pratik
31809f35ee Added new "Step 9" - Scheduling daily update download 2019-02-11 21:18:25 +05:30
Pratik
abe16c5943 Readme file changes
- Beta testing
- Flag all dev-testings to be completed
- Add bugs
- Add Roadmaps

Script
- Bumped the version to 0.9
- Aligned the logfile name with the name of the script
- Restore Operation - Adopted the set_op_code method for determining  successes
- Restore Operations - took the remove-immutable flag code to revert_secure_authorized_key function
- Restore Operation - removed redundant operations from revert_secure_authorized_key method - as script is never goes into an existing user's .ssh folder - so no need to care for existing files
- Restore Operation - Call revert ssh key AFTER immutable file restoration has completed
- reset_op_code after all restore function & in the beginning of error segment of each step
- Bugfix - revert source list changes
- Bugfix - restore fail2ban
- Step 2 - removed checks for existing file - we never operate on existing users - so this is an useless check
- File Log - since we do not check if the last operation's success before writing to logfile - changed the tense to -ing
- Step 4 - added more file logs
- Step 6 & 7 - Instead of checking if installation succeess - check if ufw/fail2ban is installed before processing
- Step 7 - added more file logs
- Step 8 - added more file logs
2019-02-11 06:48:36 +05:30
Pratik
979e1b0657 Read me Changes
- Display all available options
- Some Typos rectified
- Updated the "Roadmap"

Script Changes
- Reliable method of determining if a service command was completed successfully
- More (and reliable) logs to the logfile
- Bugfix - SSH Reverting
- Revert source list - check success on sub-folder file restores
- Logfile - removed multiple revert success notifications
- Revert Fail2ban - Stopped deleting the jail.conf*_bkp files
- Step 4 - Default source-list - check success flag on commenting out existing source.list & on appending new CNS to sources.list (check the same 2 for *.list in sub-folders)
- Step 7 - fail2ban - check operation success on backing up jail.local, jail.conf & defaults-debian.conf files
2019-02-11 00:52:34 +05:30
Pratik
edcfae7fe8 Aligned to project rename 2019-01-29 12:40:15 +05:30
Pratik
74268c6693 Updated Readme 2019-01-29 11:43:31 +05:30
Pratik
2f8daea7e6 Bug fix 2019-01-29 10:07:39 +05:30
Pratik
fea4c400c7 Removed operations from revert_create_ssh_key
Revert UFW & Fail2Ban on SSH-only failure
2019-01-28 14:54:36 +05:30
Pratik
ce8284695a Added the readme file 2019-01-25 05:42:49 +05:30
Pratik
065307a80d - Took the SSH-only section to bottom - so if something fails mid-way user would still have access to server
- Noninteractive apt-get upgrade added
2019-01-23 07:31:49 +05:30
Pratik
07f9089e3d - Display red text for Revert Op display
- Switched to "service" from "systemctl" to  accomodate Ubuntu 14
- Bugfix
2019-01-23 05:04:27 +05:30
Pratik
91495769b4 - Added source.list change for Ubuntu
- Verbose method for deluser - on error
- Bugfix - Fail2ban config failure reverted everything. Only fail2ban needs to be reverted
- Other minor bug fixes
2019-01-23 02:48:13 +05:30
Pratik
524423e3bb Completed Fail2ban & UFW 2019-01-22 17:43:07 +05:30
Pratik
b9c482336e Added UFW & Fail2ban 2019-01-22 02:08:05 +05:30
Pratik
2383b2b073 Added "-q" option for quiet opertion 2019-01-21 20:42:45 +05:30
Pratik
94d2e2b253 Error Handling done 2019-01-21 18:49:18 +05:30
Pratik
c4de5a088b Updates 2019-01-18 09:45:16 +05:30
Pratik
c533bb8937 Updates 2019-01-16 21:51:40 +05:30
Pratik
07b240a9f7 Redirect all logs to logfile 2018-12-07 17:43:57 +05:30
Pratik
04e3daedf1 Added Console logs 2018-12-07 03:06:32 +05:30
Pratik
3d0b2eaed5 SSH_only login set
Working on Debian 9.x
2018-12-06 23:53:19 +05:30
Pratik
78afbe2558 Rudimentarily working 2018-12-05 00:43:02 +05:30
Pratik
a228d9899b Initial Empty entry 2018-11-19 04:23:08 +05:30