Skip to content

Commit 4b3e583

Browse files
author
Hunter T
committed
style(comments): update and modify style of comments
1 parent 4b57206 commit 4b3e583

3 files changed

Lines changed: 76 additions & 77 deletions

File tree

auditing/lynis-installer.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#
55
# Version: v1.0.3
66
# License: MIT License
7-
# Copyright (c) 2020-2021 Hunter T.
7+
# Copyright (c) 2020-2021 Hunter T.
88
#
9-
################################################################################
9+
########################################################################################
1010
#### [ Variables ]
1111

1212

@@ -17,11 +17,11 @@ nc=$'\033[0m'
1717

1818

1919
##### End of [ Variables ]
20-
################################################################################
20+
########################################################################################
2121
#### [ Prepping ]
2222

2323

24-
# Checks to see if this script was executed with root privilege
24+
## Check if the script was executed with root privilege.
2525
if [[ $EUID != 0 ]]; then
2626
echo "${red}Please run this script as or with root privilege${nc}" >&2
2727
echo -e "\nExiting..."
@@ -30,31 +30,31 @@ fi
3030

3131

3232
#### End of [ Prepping ]
33-
################################################################################
33+
########################################################################################
3434
#### [ Main ]
3535

3636

3737
read -rp "We will now download lynis. Press [Enter] to continue."
3838

39-
echo "Changing working directory to '/home/${SUDO_USER}'..."
39+
echo "Changing working directory to '/home/$SUDO_USER'..."
4040
cd /home/"$SUDO_USER" || {
41-
echo "${red}Failed to change working directory to '/home/${SUDO_USER}'"
42-
echo "${cyan}Lynis will download to '${PWD}'${nc}"
41+
echo "${red}Failed to change working directory to '/home/$SUDO_USER'"
42+
echo "${cyan}Lynis will download to '$PWD'$nc"
4343
}
4444

4545
echo "Downloading lynis..."
4646
git clone https://github.com/CISOfy/lynis || {
47-
echo "${red}Failed to download lynis${nc}" >&2
47+
echo "${red}Failed to download lynis$nc" >&2
4848
echo -e "\nExiting..."
4949
exit 1
5050
}
5151
echo "Changing ownership of lynis to root:root..."
5252
chown -R root:root lynis
5353

5454
echo -e "\n${green}Lynis has been downloaded to your system"
55-
echo -e "${cyan}To perform a system scan with lynis, execute the following" \
56-
"command in the lynis root directory: sudo ./lynis audit system${nc}"
55+
echo -e "${cyan}To perform a system scan with lynis, execute the following command in" \
56+
"the lynis root directory: sudo ./lynis audit system$nc"
5757

5858

5959
#### End of [ Main ]
60-
################################################################################
60+
########################################################################################

hardening/root-locker.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#
55
# Version: v1.0.3
66
# License: MIT License
7-
# Copyright (c) 2020-2021 Hunter T.
7+
# Copyright (c) 2020-2021 Hunter T.
88
#
9-
################################################################################
9+
########################################################################################
1010
#### [ Variables ]
1111

1212

@@ -19,40 +19,39 @@ nc=$'\033[0m'
1919

2020

2121
##### End of [ Variables ]
22-
################################################################################
22+
########################################################################################
2323
#### [ Prepping ]
2424

2525

26-
# Checks to see if this script was executed with root privilege
26+
## Check if this script was executed with root privilege.
2727
if [[ $EUID != 0 ]]; then
28-
echo "${red}Please run this script as or with root privilege${nc}" >&2
28+
echo "${red}Please run this script as or with root privilege$nc" >&2
2929
echo -e "\nExiting..."
3030
exit 1
3131
fi
3232

3333

3434
#### End of [ Prepping ]
35-
################################################################################
35+
########################################################################################
3636
#### [ Main ]
3737

3838

3939
read -rp "We will now disable the root account. Press [Enter] to continue."
4040

41-
# Only backs up the original shadow file
41+
## Backup 'shadow' if 'shadow.bak' doesn't already exist.
4242
if [[ ! -f $config_file_bak ]]; then
4343
echo "Backing up original 'shadow'..."
44-
cp $config_file $config_file_bak || {
44+
cp "$config_file" "$config_file_bak" || {
4545
echo "${red}Failed to back up shadow" >&2
46-
echo "${cyan}Please create a backup of the original 'shadow'" \
47-
"before continuing${nc}"
46+
echo "${cyan}Please create a backup of the original 'shadow' before continuing$nc"
4847
exit 1
4948
}
5049
fi
5150

5251
echo "Disabling root account..."
53-
passwd -dl root && echo -e "\n${green}The root account has been locked${nc}" ||
54-
echo -e "\n${red}Failed to lock the root account${nc}"
52+
passwd -dl root && echo -e "\n${green}The root account has been locked$nc" \
53+
|| echo -e "\n${red}Failed to lock the root account$nc"
5554

5655

5756
#### End of [ Main ]
58-
################################################################################
57+
########################################################################################

hardening/sshd.sh

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/bin/bash
22
#
3-
# Hardens sshd by modifying '/etc/ssh/sshd_config'
3+
# Hardens sshd by modifying '/etc/ssh/sshd_config'.
44
#
5-
# Note: This configures sshd_config to the recommendations of the security
6-
# auditing tool knonw as Lynis (https://github.com/CISOfy/lynis)
5+
# Note: This configures sshd_config to the recommendations of the security auditing tool
6+
# knonw as Lynis (https://github.com/CISOfy/lynis).
77
#
88
# Version: v1.0.3
99
# License: MIT License
10-
# Copyright (c) 2020-2021 Hunter T.
10+
# Copyright (c) 2020-2021 Hunter T.
1111
#
12-
################################################################################
12+
########################################################################################
1313
#### [ Variables ]
1414

1515

@@ -21,125 +21,125 @@ nc=$'\033[0m'
2121

2222

2323
##### End of [ Variables ]
24-
################################################################################
24+
########################################################################################
2525
#### [ Prepping ]
2626

2727

28-
# Checks to see if this script was executed with root privilege
28+
## Check if the script was executed with root privilege.
2929
if [[ $EUID != 0 ]]; then
30-
echo "${red}Please run this script as or with root privilege${nc}" >&2
30+
echo "${red}Please run this script as or with root privilege$nc" >&2
3131
echo -e "\nExiting..."
3232
exit 1
3333
fi
3434

35-
# Confirms that sshd_config exists
35+
## Confirm that 'sshd_config' exists.
3636
if [[ ! -f $config_file ]]; then
3737
echo "${red}'sshd_config' doesn't exist" >&2
38-
echo "${cyan}sshd-server may not be installed${nc}"
38+
echo "${cyan}sshd-server may not be installed$nc"
3939
echo -e "\nExiting..."
4040
exit 1
4141
fi
4242

4343

4444
#### End of [ Prepping ]
45-
################################################################################
45+
########################################################################################
4646
#### [ Main ]
4747

4848

4949
read -rp "We will now harden sshd. Press [Enter] to continue."
5050

51-
# Only backs up the original sshd_config
51+
## Backup 'sshd_config' if 'sshd_config.bak' doesn't already exist.
5252
if [[ ! -f $config_file_bak ]]; then
5353
echo "Backing up original 'sshd_config'..."
5454
cp $config_file $config_file_bak || {
5555
echo "${red}Failed to back up sshd_config" >&2
5656
echo "${cyan}Please create a backup of the original 'sshd_config'" \
57-
"before continuing${nc}"
57+
"before continuing$nc"
5858
exit 1
5959
}
6060
fi
6161

6262
echo "Setting LogLevel VERBOSE..."
63-
sed -i 's/\(#\)\?LogLevel\(.*\)\?/LogLevel VERBOSE/g' "$config_file" ||
64-
echo "${red}Failed to set LogLevel VERBOSE${nc}"
63+
sed -i 's/\(#\)\?LogLevel\(.*\)\?/LogLevel VERBOSE/g' "$config_file" \
64+
|| echo "${red}Failed to set LogLevel VERBOSE$nc"
6565

6666
echo "Setting LoginGraceTime 30..."
67-
sed -i 's/\(#\)\?LoginGraceTime\(.*\)\?/LoginGraceTime 30/g' "$config_file" ||
68-
echo "${red}Failed to set LoginGraceTime 30${nc}"
67+
sed -i 's/\(#\)\?LoginGraceTime\(.*\)\?/LoginGraceTime 30/g' "$config_file" \
68+
|| echo "${red}Failed to set LoginGraceTime 30$nc"
6969

7070
echo "Setting PermitRootLogin no..."
71-
sed -i 's/\(#\)\?PermitRootLogin\(.*\)\?/PermitRootLogin no/g' "$config_file" ||
72-
echo "${red}Failed to set PermitRootLogin no${nc}"
71+
sed -i 's/\(#\)\?PermitRootLogin\(.*\)\?/PermitRootLogin no/g' "$config_file" \
72+
|| echo "${red}Failed to set PermitRootLogin no$nc"
7373

7474
echo "Setting MaxAuthTries 3..."
75-
sed -i 's/\(#\)\?MaxAuthTries\(.*\)\?/MaxAuthTries 3/g' "$config_file" ||
76-
echo "${red}Failed to set MaxAuthTries 3${nc}"
75+
sed -i 's/\(#\)\?MaxAuthTries\(.*\)\?/MaxAuthTries 3/g' "$config_file" \
76+
|| echo "${red}Failed to set MaxAuthTries 3$nc"
7777

7878
echo "Setting MaxSessions 2..."
79-
sed -i 's/\(#\)\?MaxSessions\(.*\)\?/MaxSessions 2/g' "$config_file" ||
80-
echo "${red}Failed to set MaxSessions 2${nc}"
79+
sed -i 's/\(#\)\?MaxSessions\(.*\)\?/MaxSessions 2/g' "$config_file" \
80+
|| echo "${red}Failed to set MaxSessions 2$nc"
8181

8282
echo "Setting PubkeyAuthentication yes..."
83-
sed -i 's/\(#\)\?PubkeyAuthentication\(.*\)\?/PubkeyAuthentication yes/g' "$config_file" ||
84-
echo "${red}Failed to set PubkeyAuthentication yes${nc}"
83+
sed -i 's/\(#\)\?PubkeyAuthentication\(.*\)\?/PubkeyAuthentication yes/g' "$config_file" \
84+
|| echo "${red}Failed to set PubkeyAuthentication yes$nc"
8585

8686
# Uncomment only if an ssh key has been set
8787
#echo "Setting PasswordAuthentication no..."
88-
#sed -i 's/\(#\)\?PasswordAuthentication\(.*\)\?/PasswordAuthentication no/g' "$config_file" ||
89-
# echo "${red}Failed to set PasswordAuthentication no${nc}"
88+
#sed -i 's/\(#\)\?PasswordAuthentication\(.*\)\?/PasswordAuthentication no/g' "$config_file" \
89+
# || echo "${red}Failed to set PasswordAuthentication no$nc"
9090

9191
echo "Setting PermitEmptyPasswords no..."
92-
sed -i 's/\(#\)\?PermitEmptyPasswords\(.*\)\?/PermitEmptyPasswords no/g' "$config_file" ||
93-
echo "${red}Failed to set PermitEmptyPasswords no${nc}"
92+
sed -i 's/\(#\)\?PermitEmptyPasswords\(.*\)\?/PermitEmptyPasswords no/g' "$config_file" \
93+
|| echo "${red}Failed to set PermitEmptyPasswords no$nc"
9494

9595
echo "Setting ChallengeResponseAuthentication no..."
9696
sed -i 's/\(#\)\?ChallengeResponseAuthentication\(.*\)\?/ChallengeResponseAuthentication no/g' \
97-
"$config_file" || echo "${red}Failed to set ChallengeResponseAuthentication no${nc}"
97+
"$config_file" \ || echo "${red}Failed to set ChallengeResponseAuthentication no$nc"
9898

9999
echo "Setting UsePAM yes..."
100-
sed -i 's/\(#\)\?UsePAM\(.*\)\?/UsePAM yes/g' "$config_file" ||
101-
echo "${red}Failed to set UsePAM yes${nc}"
100+
sed -i 's/\(#\)\?UsePAM\(.*\)\?/UsePAM yes/g' "$config_file" \
101+
|| echo "${red}Failed to set UsePAM yes$nc"
102102

103103
echo "Setting AllowAgentForwarding no..."
104-
sed -i 's/\(#\)\?AllowAgentForwarding\(.*\)\?/AllowAgentForwarding no/g' "$config_file" ||
105-
echo "${red}Failed to set AllowAgentForwarding no${nc}"
104+
sed -i 's/\(#\)\?AllowAgentForwarding\(.*\)\?/AllowAgentForwarding no/g' "$config_file" \
105+
|| echo "${red}Failed to set AllowAgentForwarding no$nc"
106106

107107
echo "Setting AllowTcpForwarding no..."
108-
sed -i 's/\(#\)\?AllowTcpForwarding\(.*\)\?/AllowTcpForwarding no/g' "$config_file" ||
109-
echo "${red}Failed to set AllowTcpForwarding no${nc}"
108+
sed -i 's/\(#\)\?AllowTcpForwarding\(.*\)\?/AllowTcpForwarding no/g' "$config_file" \
109+
|| echo "${red}Failed to set AllowTcpForwarding no$nc"
110110

111111
echo "Setting X11Forwarding no..."
112-
sed -i 's/\(#\)\?X11Forwarding\(.*\)\?/X11Forwarding no/g' "$config_file" ||
113-
echo "${red}Failed to set X11Forwarding no${nc}"
112+
sed -i 's/\(#\)\?X11Forwarding\(.*\)\?/X11Forwarding no/g' "$config_file" \
113+
|| echo "${red}Failed to set X11Forwarding no$nc"
114114

115115
echo "Setting PrintMotd no..."
116-
sed -i 's/\(#\)\?PrintMotd\(.*\)\?/PrintMotd no/g' "$config_file" ||
117-
echo "${red}Failed to set PrintMotd no${nc}"
116+
sed -i 's/\(#\)\?PrintMotd\(.*\)\?/PrintMotd no/g' "$config_file" \
117+
|| echo "${red}Failed to set PrintMotd no$nc"
118118

119119
echo "Setting TCPKeepAlive no..."
120-
sed -i 's/\(#\)\?TCPKeepAlive\(.*\)\?/TCPKeepAlive no/g' "$config_file" ||
121-
echo "${red}Failed to set TCPKeepAlive no${nc}"
120+
sed -i 's/\(#\)\?TCPKeepAlive\(.*\)\?/TCPKeepAlive no/g' "$config_file" \
121+
|| echo "${red}Failed to set TCPKeepAlive no$nc"
122122

123123
echo "Setting Compression no..."
124-
sed -i 's/\(#\)\?Compression\(.*\)\?/Compression no/g' "$config_file" ||
125-
echo "${red}Failed to set Compression no${nc}"
124+
sed -i 's/\(#\)\?Compression\(.*\)\?/Compression no/g' "$config_file" \
125+
|| echo "${red}Failed to set Compression no$nc"
126126

127127
echo "Setting ClientAliveInterval 300..."
128-
sed -i 's/\(#\)\?ClientAliveInterval\(.*\)\?/ClientAliveInterval 300/g' "$config_file" ||
129-
echo "${red}Failed to set ClientAliveInterval 30${nc}"
128+
sed -i 's/\(#\)\?ClientAliveInterval\(.*\)\?/ClientAliveInterval 300/g' "$config_file" \
129+
|| echo "${red}Failed to set ClientAliveInterval 30$nc"
130130

131131
echo "Setting ClientAliveCountMax 2..."
132-
sed -i 's/\(#\)\?ClientAliveCountMax\(.*\)\?/ClientAliveCountMax 2/g' "$config_file" ||
133-
echo "${red}Failed to set ClientAliveCountMax 2${nc}"
132+
sed -i 's/\(#\)\?ClientAliveCountMax\(.*\)\?/ClientAliveCountMax 2/g' "$config_file" \
133+
|| echo "${red}Failed to set ClientAliveCountMax 2$nc"
134134

135135
echo -e "\nRestarting sshd..."
136136
systemctl restart sshd
137137

138138
echo -e "\nDone"
139-
echo -e "${cyan}NOTE: It is highly recommended to manually:\n1) Change" \
140-
"sshd default port (22) to something else\n2) Add 'AllowUsers [your" \
141-
"username]' to the bottom of 'sshd_config'${nc}"
139+
echo -e "${cyan}NOTE: It is highly recommended to manually:\n1) Change sshd default" \
140+
"port (22) to something else\n2) Add 'AllowUsers [your username]' to the bottom" \
141+
"of 'sshd_config'$nc"
142142

143143

144144
#### End of [ Main ]
145-
################################################################################
145+
########################################################################################

0 commit comments

Comments
 (0)