Fix issue with sshd_config for PasswordAuthentication, AddressFamily.
This commit is contained in:
parent
0d8c8d264b
commit
226d1e292c
16
setup.sh
16
setup.sh
@ -100,10 +100,18 @@ if [ -f "$sshd_config" ]; then
|
|||||||
sed -i 's/^PermitRootLogin .*/PermitRootLogin no/' "$sshd_config" || echo "PermitRootLogin no" >> "$sshd_config"
|
sed -i 's/^PermitRootLogin .*/PermitRootLogin no/' "$sshd_config" || echo "PermitRootLogin no" >> "$sshd_config"
|
||||||
|
|
||||||
# Set PasswordAuthentication to no
|
# Set PasswordAuthentication to no
|
||||||
sed -i 's/^PasswordAuthentication .*/PasswordAuthentication no/' "$sshd_config" || echo "PasswordAuthentication no" >> "$sshd_config"
|
if grep -q '^#PasswordAuthentication' "$sshd_config"; then
|
||||||
|
sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication no/' "$sshd_config"
|
||||||
|
else
|
||||||
|
sed -i 's/^PasswordAuthentication .*/PasswordAuthentication no/' "$sshd_config" || echo "PasswordAuthentication no" >> "$sshd_config"
|
||||||
|
fi
|
||||||
|
|
||||||
# Ensure AddressFamily inet is not commented out
|
# Ensure AddressFamily inet is set
|
||||||
sed -i 's/^#\?\(AddressFamily inet\)/\1/' "$sshd_config"
|
if grep -q '^#AddressFamily' "$sshd_config"; then
|
||||||
|
sed -i 's/^#AddressFamily.*/AddressFamily inet/' "$sshd_config"
|
||||||
|
else
|
||||||
|
sed -i 's/^AddressFamily .*/AddressFamily inet/' "$sshd_config" || echo "AddressFamily inet" >> "$sshd_config"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "sshd_config file not found. Exiting."
|
echo "sshd_config file not found. Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
@ -124,4 +132,4 @@ systemctl restart sshd
|
|||||||
# Prompt for Docker installation
|
# Prompt for Docker installation
|
||||||
prompt_for_docker_install
|
prompt_for_docker_install
|
||||||
|
|
||||||
echo "System update complete! Timezone set to $timezone, hostname set to $hostname, /etc/hosts updated, and sshd_config modified."
|
echo "System update complete! Timezone set to $timezone, hostname set to $hostname, /etc/hosts updated, and sshd_config modified."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user