2021-06-12 20:47:54 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# stdin: default config
|
|
|
|
# stdout: modified config
|
|
|
|
|
|
|
|
# save stdin (content of /etc/ssh/sshd_config) in variable
|
|
|
|
stdin=$(cat)
|
|
|
|
|
2021-06-12 23:42:34 +02:00
|
|
|
# assertions
|
2021-06-12 23:53:25 +02:00
|
|
|
echo "$stdin" | grep --quiet '^UsePAM yes$'
|
2021-06-12 20:47:54 +02:00
|
|
|
#
|
2021-07-02 11:43:13 +02:00
|
|
|
echo "$stdin" | grep --quiet '^#PermitRootLogin\s*$'
|
|
|
|
echo "$stdin" | grep --quiet '^#PubkeyAuthentication\s*$'
|
|
|
|
echo "$stdin" | grep --quiet '^#PasswordAuthentication\s*$'
|
|
|
|
echo "$stdin" | grep --quiet '^#PermitEmptyPasswords\s*$'
|
|
|
|
echo "$stdin" | grep --quiet '^#X11Forwarding\s*$'
|
2021-06-12 20:47:54 +02:00
|
|
|
|
|
|
|
sed '
|
2021-07-02 11:43:13 +02:00
|
|
|
s|^#PermitRootLogin\s*$|PermitRootLogin no|;
|
|
|
|
s|^#PubkeyAuthentication\s*$|PubkeyAuthentication yes|;
|
|
|
|
s|^#PasswordAuthentication\s*$|PasswordAuthentication no|;
|
|
|
|
s|^#PermitEmptyPasswords\s*$|PermitEmptyPasswords no|;
|
|
|
|
s|^#X11Forwarding\s*$|X11Forwarding no|
|
2021-06-12 20:47:54 +02:00
|
|
|
' <<< "$stdin"
|