File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed
Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -971,8 +971,12 @@ sed -i "s/[#]LoginGraceTime [[:digit:]]m/LoginGraceTime 1m/g" /etc/ssh/sshd_conf
971971
972972# Disable SSH suffix broadcast
973973if [ -z " $( grep " ^DebianBanner no" /etc/ssh/sshd_config) " ]; then
974- echo ' ' >> /etc/ssh/sshd_config
975- echo ' DebianBanner no' >> /etc/ssh/sshd_config
974+ sed -i ' /^[#]Banner .*/a DebianBanner no' /etc/ssh/sshd_config
975+ if [ -z " $( grep " ^DebianBanner no" /etc/ssh/sshd_config) " ]; then
976+ # If first attempt fails just add it
977+ echo ' ' >> /etc/ssh/sshd_config
978+ echo ' DebianBanner no' >> /etc/ssh/sshd_config
979+ fi
976980fi
977981
978982# Restart SSH daemon
Original file line number Diff line number Diff line change @@ -971,8 +971,12 @@ sed -i "s/[#]LoginGraceTime [[:digit:]]m/LoginGraceTime 1m/g" /etc/ssh/sshd_conf
971971
972972# Disable SSH suffix broadcast
973973if [ -z " $( grep " ^DebianBanner no" /etc/ssh/sshd_config) " ]; then
974- echo ' ' >> /etc/ssh/sshd_config
975- echo ' DebianBanner no' >> /etc/ssh/sshd_config
974+ sed -i ' /^[#]Banner .*/a DebianBanner no' /etc/ssh/sshd_config
975+ if [ -z " $( grep " ^DebianBanner no" /etc/ssh/sshd_config) " ]; then
976+ # If first attempt fails just add it
977+ echo ' ' >> /etc/ssh/sshd_config
978+ echo ' DebianBanner no' >> /etc/ssh/sshd_config
979+ fi
976980fi
977981
978982# Restart SSH daemon
You can’t perform that action at this time.
0 commit comments