41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
###############################################################
|
|
###
|
|
### ssh server konfig
|
|
###
|
|
###############################################################
|
|
|
|
START='### unique ssh config start ###'
|
|
|
|
END='### unique ssh config end ###'
|
|
|
|
CFG='Match User conetadm
|
|
PasswordAuthentication yes
|
|
PubkeyAuthentication yes
|
|
AllowUsers conetadm@10.0.0.0/8 conetadm@192.168.0.0/16 conetadm@172.16.0.0/12 conetadm@195.20.133.0/24 conetadm@149.13.94.0/24
|
|
|
|
Match User ansible
|
|
PasswordAuthentication no
|
|
PubkeyAuthentication yes
|
|
AllowUsers ansible@10.0.0.0/8 ansible@192.168.0.0/16 ansible@172.16.0.0/12'
|
|
|
|
UNIQ="$START
|
|
$CFG
|
|
$END"
|
|
|
|
grep "$START" /etc/ssh/sshd_config
|
|
if [ "$?" == "1" ]
|
|
then
|
|
echo uniq Eintrag nicht vorhanden, wird angehängt
|
|
else
|
|
echo uniq Eintrag gefunden, wird ersetzt
|
|
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bu
|
|
sed -i "/$START/,/$END/d" /etc/ssh/sshd_config
|
|
fi
|
|
echo "$UNIQ" >> /etc/ssh/sshd_config
|
|
|
|
sed -i "s/^[# ]*PermitRootLogin.*$/PermitRootLogin no/g" /etc/ssh/sshd_config
|
|
sed -i "s/^[# ]*AllowTcpForwarding.*$/AllowTcpForwarding no/g" /etc/ssh/sshd_config
|
|
|
|
systemctl restart sshd |