Skip to content

Commit 6a16545

Browse files
Merge pull request #12 from StrangeRanger/dev
2 parents 13ee5e2 + 89fdf43 commit 6a16545

6 files changed

Lines changed: 197 additions & 49 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## v1.0.6 - 2024-04-13
8+
9+
### Changed
10+
11+
- Improved documentation of code.
12+
13+
## v1.0.5 - 2022-07-13
14+
15+
### Changed
16+
17+
- Changed how the variables used to change the color of output text, are formatted, in the hopes of increasing portability.
18+
- Exit codes beyond 1, were reverted back to 1.
19+
20+
## v1.0.4 - 2022-07-10
21+
22+
### Changed
23+
24+
- Modified exit codes.
25+
26+
## v1.0.3 - 2020-12-01
27+
28+
### Changed
29+
30+
- Changed some of the output text.
31+
32+
### Fixed
33+
34+
- Added missing variable to `echo`, resulting in the text color to remain cyan.
35+
36+
## v1.0.2 - N/A
37+
38+
### Added
39+
40+
- Added error catching when attempting to download lynis
41+
42+
### Fixed
43+
44+
- Fixed mistyped environmental variable from 'USER_SUDO' to 'SUDO_USER'
45+
46+
## v1.0.1 - N/A
47+
48+
### Added
49+
50+
- Now prompts the user before performing actions
51+
52+
### Fixed
53+
54+
- Fixed script not wanting to run as root
55+
56+
## v1.0.0 - N/A
57+
58+
- Initial creation
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
#!/bin/bash
22
#
3-
# A script for installing and running lynis with recommended options.
3+
# This script downloads a security auditing tool called Lynis, designed to scan a system
4+
# and identify security issues, and provides recommendations on how to better secure it.
5+
# Lynis, unless an error is encountered, will always be downloaded to the user's root
6+
# directory (/home/USERNAME/).
47
#
5-
# Version: v1.0.5
8+
# Version: v1.0.6
69
# License: MIT License
7-
# Copyright (c) 2020-2023 Hunter T. (StrangeRanger)
10+
# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
811
#
912
########################################################################################
10-
#### [ Variables ]
13+
####[ Script Wide Variables ]###########################################################
1114

1215

1316
green="$(printf '\033[0;32m')"
@@ -16,9 +19,7 @@ red="$(printf '\033[1;31m')"
1619
nc="$(printf '\033[0m')"
1720

1821

19-
##### End of [ Variables ]
20-
########################################################################################
21-
#### [ Prepping ]
22+
####[ Prepping ]########################################################################
2223

2324

2425
## Check if the script was executed with root privilege.
@@ -29,9 +30,7 @@ if [[ $EUID != 0 ]]; then
2930
fi
3031

3132

32-
#### End of [ Prepping ]
33-
########################################################################################
34-
#### [ Main ]
33+
####[ Main ]############################################################################
3534

3635

3736
read -rp "We will now download lynis. Press [Enter] to continue."
@@ -54,7 +53,3 @@ chown -R root:root lynis
5453
echo -e "\n${green}Lynis has been downloaded to your system"
5554
echo -e "${cyan}To perform a system scan with lynis, execute the following command in" \
5655
"the lynis root directory: sudo ./lynis audit system${nc}"
57-
58-
59-
#### End of [ Main ]
60-
########################################################################################

hardening/Root Locker/CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## v1.0.6 - 2024-04-13
8+
9+
### Changed
10+
11+
- Improved documentation of code.
12+
13+
## v1.0.5 - 2022-07-13
14+
15+
### Changed
16+
17+
- Changed how the variables used to change the color of output text, are formatted, in the hopes of increasing portability.
18+
- Exit codes beyond 1, were reverted back to 1.
19+
20+
## v1.0.4 - 2022-07-10
21+
22+
### Changed
23+
24+
- Modified exit codes.
25+
- No longer backs up `/etc/shadow`.
26+
27+
## v1.0.3 - 2020-12-01
28+
29+
### Changed
30+
31+
- Changed commenting style.
32+
33+
### Fixed
34+
35+
- Added missing variable to `echo`, resulting in the text color to remain cyan.
36+
37+
## v1.0.2 - N/A
38+
39+
### Changed
40+
41+
- Changed placement of `read -p "We will now disable the root account. Press [Enter] to continue."`.
42+
43+
## v1.0.0 - N/A
44+
45+
- Initial creation.
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
#!/bin/bash
22
#
3-
# Locks the root account and erases it's current password.
3+
# This script locks and removes the root account's password (if one is set). This
4+
# prevents users from successfully logging into the root account via su. Note that it
5+
# doesn't prevent users from becoming root via methods such as sudo su.
46
#
5-
# Version: v1.0.5
7+
# Version: v1.0.6
68
# License: MIT License
7-
# Copyright (c) 2020-2023 Hunter T. (StrangeRanger)
9+
# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
810
#
911
########################################################################################
10-
#### [ Variables ]
12+
####[ Script Wide Variables ]###########################################################
1113

1214

1315
green="$(printf '\033[0;32m')"
1416
red="$(printf '\033[1;31m')"
1517
nc="$(printf '\033[0m')"
1618

1719

18-
##### End of [ Variables ]
19-
########################################################################################
20-
#### [ Prepping ]
20+
####[ Prepping ]########################################################################
2121

2222

2323
## Check if this script was executed with root privilege.
@@ -28,9 +28,7 @@ if [[ $EUID != 0 ]]; then
2828
fi
2929

3030

31-
#### End of [ Prepping ]
32-
########################################################################################
33-
#### [ Main ]
31+
####[ Main ]############################################################################
3432

3533

3634
read -rp "We will now disable the root account. Press [Enter] to continue."
@@ -43,7 +41,3 @@ passwd -dl root || {
4341
}
4442

4543
echo -e "\n${green}The root account has been locked${nc}"
46-
47-
48-
#### End of [ Main ]
49-
########################################################################################
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## v1.1.3 - 2024-04-13
8+
9+
### Changed
10+
11+
- Improved documentation and comments of code.
12+
13+
## v1.1.1 - 2022-07-13
14+
15+
### Changed
16+
17+
- Changed how the variables used to change the color of output text, are formatted, in the hopes of increasing portability.
18+
- Exit codes beyond 1, were reverted back to 1.
19+
- Other efficiency changes.
20+
21+
## v1.1.0 - 2022-07-10
22+
23+
### Added
24+
25+
- Sets `KbdInteractiveAuthentication` to `KbdInteractiveAuthentication no`.
26+
- This setting is introduced in Ubuntu 22.04, seeming to replace `ChallengeResponseAuthentication`.
27+
- Asks if the end user would like to overwrite the existing backup of `sshd_config`, if it exists.
28+
29+
### Changed
30+
31+
- Modified exit codes.
32+
- Modified the output text, depending on whether the specific configurations have already been set.
33+
- Updated the flags and regex used by `sed` to set the configurations.
34+
35+
## v1.0.3 - 2020-12-01
36+
37+
### Changed
38+
39+
- Changed commenting style.
40+
41+
### Fixed
42+
43+
- Added missing variable to `echo`, resulting in the text color to remain cyan.
44+
45+
## v1.0.2 - N/A
46+
47+
### Added
48+
49+
- Checks if `sshd_config` exists before attempting to modify the file.
50+
51+
## v1.0.1 - N/A
52+
53+
### Added
54+
55+
- Now prompts the user before performing actions.
56+
57+
### Fixed
58+
59+
- Fixed script not wanting to run as root.
60+
61+
## v1.0.0
62+
63+
- Initial creation.
Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/bin/bash
22
#
3-
# Hardens sshd by modifying the configurations of '/etc/ssh/sshd_config'.
3+
# This script hardens the sshd-server, by modifying it's configuration file
4+
# (sshd_config).
45
#
56
# Note: This configures sshd_config to the recommendations of the security auditing tool
67
# knonw as Lynis (https://github.com/CISOfy/lynis).
78
#
89
# Version: v1.1.2
910
# License: MIT License
10-
# Copyright (c) 2020-2023 Hunter T. (StrangeRanger)
11+
# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
1112
#
1213
########################################################################################
13-
#### [ Variables ]
14+
####[ Script Wide Variables ]###########################################################
1415

1516

1617
config_file_bak="/etc/ssh/sshd_config.bak"
@@ -21,27 +22,25 @@ red="$(printf '\033[1;31m')"
2122
nc="$(printf '\033[0m')"
2223

2324

24-
#### End of [ Variables ]
25-
########################################################################################
26-
#### [ Functions ]
25+
####[ Functions ]#######################################################################
2726

2827

29-
########
28+
####
3029
# Cleanly exit the script.
3130
#
3231
# Arguments:
33-
# $1 - required
34-
# Exit status code.
35-
########
32+
# - $1: exit_code (Required)
33+
# - Description: The exit code to exit the script with.
34+
####
3635
clean_up() {
36+
local exit_code="$1"
37+
3738
echo -e "\nExiting..."
38-
exit "$1"
39+
exit "$exit_code"
3940
}
4041

4142

42-
#### End of [ Functions ]
43-
########################################################################################
44-
#### [ Prepping ]
43+
####[ Prepping ]########################################################################
4544

4645

4746
## Check if the script was executed with root privilege.
@@ -58,9 +57,7 @@ if [[ ! -f $config_file ]]; then
5857
fi
5958

6059

61-
#### End of [ Prepping ]
62-
########################################################################################
63-
#### [ Main ]
60+
####[ Main ]############################################################################
6461

6562

6663
read -rp "We will now harden sshd. Press [Enter] to continue."
@@ -244,7 +241,3 @@ echo -e "${cyan}It is highly recommended to manually:
244241
1) Change the default sshd port (22)
245242
2) Disable PasswordAuthentication in favor of PubkeyAuthentication
246243
3) Add 'AllowUsers [your username]' to the bottom of 'sshd_config'${nc}"
247-
248-
249-
#### End of [ Main ]
250-
########################################################################################

0 commit comments

Comments
 (0)