setup/init-sshd.sh aktualisiert
Ansible User in eigenen Abschnitt ausgelagert. Anpassung der Start/Ende Markierung zur Kompatibilität mit dem CyberArk Onboarding Skript
This commit is contained in:
@@ -6,34 +6,51 @@
|
|||||||
###
|
###
|
||||||
###############################################################
|
###############################################################
|
||||||
|
|
||||||
START='### unique conet sshd config start ###'
|
START1='### unique conet sshd config start ###'
|
||||||
|
END1='### unique conet sshd config end ###'
|
||||||
END='### unique conet sshd config end ###'
|
CFG1='Match User conetadm
|
||||||
|
|
||||||
CFG='Match User conetadm
|
|
||||||
PasswordAuthentication yes
|
PasswordAuthentication yes
|
||||||
PubkeyAuthentication 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
|
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
|
UNIQ1="$START1
|
||||||
|
$CFG1
|
||||||
|
$END1"
|
||||||
|
|
||||||
|
START2='### unique ansible sshd config start ###'
|
||||||
|
END2='### unique ansible sshd config end ###'
|
||||||
|
CFG2='Match User ansible
|
||||||
PasswordAuthentication no
|
PasswordAuthentication no
|
||||||
PubkeyAuthentication yes
|
PubkeyAuthentication yes
|
||||||
AllowUsers ansible@10.0.0.0/8 ansible@192.168.0.0/16 ansible@172.16.0.0/12'
|
AllowUsers ansible@10.0.0.0/8 ansible@192.168.0.0/16 ansible@172.16.0.0/12'
|
||||||
|
|
||||||
UNIQ="$START
|
UNIQ2="$START2
|
||||||
$CFG
|
$CFG2
|
||||||
$END"
|
$END2"
|
||||||
|
|
||||||
grep "$START" /etc/ssh/sshd_config
|
grep "$START1" /etc/ssh/sshd_config
|
||||||
if [ "$?" == "1" ]
|
if [ "$?" == "1" ]
|
||||||
then
|
then
|
||||||
echo uniq Eintrag nicht vorhanden, wird angehängt
|
echo 1. uniq Eintrag nicht vorhanden, wird angehängt
|
||||||
else
|
else
|
||||||
echo uniq Eintrag gefunden, wird ersetzt
|
echo 1. uniq Eintrag gefunden, wird ersetzt
|
||||||
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bu
|
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bu
|
||||||
sed -i "/$START/,/$END/d" /etc/ssh/sshd_config
|
sed -i "/$START1/,/$END1/d" /etc/ssh/sshd_config
|
||||||
fi
|
fi
|
||||||
echo "$UNIQ" >> /etc/ssh/sshd_config
|
echo "$UNIQ1" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
|
||||||
|
grep "$START2" /etc/ssh/sshd_config
|
||||||
|
if [ "$?" == "1" ]
|
||||||
|
then
|
||||||
|
echo 2. uniq Eintrag nicht vorhanden, wird angehängt
|
||||||
|
else
|
||||||
|
echo 2. uniq Eintrag gefunden, wird ersetzt
|
||||||
|
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bu
|
||||||
|
sed -i "/$START2/,/$END2/d" /etc/ssh/sshd_config
|
||||||
|
fi
|
||||||
|
echo "$UNIQ2" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
|
||||||
sed -i "s/^[# ]*PermitRootLogin.*$/PermitRootLogin no/g" /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
|
sed -i "s/^[# ]*AllowTcpForwarding.*$/AllowTcpForwarding no/g" /etc/ssh/sshd_config
|
||||||
|
|||||||
Reference in New Issue
Block a user