2023-01-27 00:19:52 -08:00
|
|
|
{{- if ne .host.distro.family "windows" }}
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-01-27 01:28:02 -08:00
|
|
|
# sshd_config hash: {{ include (joinPath .host.home ".ssh" "system" "sshd_config") | sha256sum }}
|
|
|
|
# banner hash: {{ include (joinPath .host.home ".ssh" "system" "banner") | sha256sum }}
|
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
2023-01-27 00:19:52 -08:00
|
|
|
### Update /etc/ssh/sshd_config if environment is not WSL
|
|
|
|
if [[ ! "$(grep Microsoft /proc/version)" ]]; then
|
|
|
|
if [ -d /etc/ssh ]; then
|
|
|
|
logg info 'Copying ~/.ssh/system/banner to /etc/ssh/banner'
|
|
|
|
sudo cp -f "$HOME/.ssh/system/banner" /etc/ssh/banner
|
|
|
|
|
|
|
|
logg info 'Copying ~/.ssh/system/sshd_config to /etc/ssh/sshd_config'
|
|
|
|
sudo cp -f "$HOME/.ssh/system/sshd_config" /etc/ssh/sshd_config
|
|
|
|
|
|
|
|
### Restart SSH server
|
|
|
|
if [ -d /Applications ] && [ -d /System ]; then
|
|
|
|
# macOS
|
|
|
|
logg info 'Running `sudo launchctl stop com.openssh.sshd`'
|
|
|
|
sudo launchctl stop com.openssh.sshd
|
|
|
|
logg info 'Running `sudo launchctl start com.openssh.sshd`'
|
|
|
|
sudo launchctl start com.openssh.sshd
|
|
|
|
else
|
|
|
|
# Linux
|
|
|
|
logg info 'Enabling the `sshd` service'
|
|
|
|
sudo systemctl enable sshd
|
|
|
|
logg info 'Restarting the `sshd` service'
|
2023-01-27 01:28:02 -08:00
|
|
|
sudo systemctl restart sshd
|
2023-01-27 00:19:52 -08:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
logg warn 'The /etc/ssh folder does not exist'
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
logg info 'Skipping sshd_config application since environment is WSL'
|
|
|
|
fi
|
|
|
|
|
|
|
|
{{ end -}}
|