2023-02-01 12:45:33 -08:00
|
|
|
{{- if eq .host.distro.family "linux" -}}
|
2023-01-28 19:49:06 -08:00
|
|
|
#!/usr/bin/env bash
|
2023-04-15 16:14:30 -07:00
|
|
|
# @file Endlessh Configuration
|
|
|
|
# @brief Applies the Endlessh configuration and starts the service on Linux systems
|
|
|
|
# @description
|
|
|
|
# Endlessh is a endless SSH tarpit that slowly shows an infinitely long SSH welcome banner on the default
|
|
|
|
# SSH port. It is intended to break unsophisticated malware that targets SSH.
|
|
|
|
#
|
|
|
|
# If the `endlessh` program is installed, this script applies the configuration stored in `home/private_dot_ssh/endlessh/config.tmpl`
|
|
|
|
# (that unpacks with Chezmoi to `~/.ssh/endlessh/config`) to the system location and then starts the service.
|
|
|
|
#
|
|
|
|
# **Note:** _This script runs under the assumption that the actual SSH port which is defined in `home/.chezmoidata.yaml`
|
|
|
|
# is assigned to a non-standard port like 2214. This allows the default port to be used for `endlessh`._
|
|
|
|
#
|
|
|
|
# ## Links
|
|
|
|
#
|
|
|
|
# * [Endlessh GitHub repository](https://github.com/skeeto/endlessh)
|
|
|
|
# * [Endlessh configuration](https://github.com/megabyte-labs/install.doctor/blob/master/home/private_dot_ssh/endlessh/config.tmpl)
|
2023-01-28 19:49:06 -08:00
|
|
|
|
2023-02-01 13:09:14 -08:00
|
|
|
# endlessh config hash: {{- include (joinPath .host.home ".ssh" "endlessh" "config") | sha256sum -}}
|
2023-01-28 19:49:06 -08:00
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
|
|
|
### Update /etc/endlessh/config if environment is not WSL
|
2023-02-15 19:14:33 -08:00
|
|
|
if [[ ! "$(test -d proc && grep Microsoft /proc/version > /dev/null)" ]]; then
|
2023-01-28 19:49:06 -08:00
|
|
|
if command -v endlessh > /dev/null; then
|
|
|
|
if [ -d /etc/endlessh ]; then
|
|
|
|
logg info 'Copying ~/.ssh/endlessh/config to /etc/endlessh/config'
|
|
|
|
sudo cp -f "$HOME/.ssh/endlessh/config" /etc/endlessh/config
|
|
|
|
|
|
|
|
### Restart / enable Endlessh
|
|
|
|
logg info 'Enabling the `endlessh` service'
|
|
|
|
sudo systemctl enable endlessh
|
|
|
|
logg info 'Restarting the `endlessh` service'
|
|
|
|
sudo systemctl restart endlessh
|
|
|
|
else
|
|
|
|
logg warn 'The /etc/endlessh folder does not exist'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
logg info 'Skipping Endlessh configuration because the `endlessh` executable is not available in the PATH'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
logg info 'Skipping Endlessh configuration since environment is WSL'
|
|
|
|
fi
|
|
|
|
|
|
|
|
{{ end -}}
|