Files
configng/tools/modules/system/toggle_ssh_lastlog.sh
2025-02-13 08:34:16 +01:00

31 lines
818 B
Bash

module_options+=(
["toggle_ssh_lastlog,author"]="@Tearran"
["toggle_ssh_lastlog,ref_link"]=""
["toggle_ssh_lastlog,feature"]="toggle_ssh_lastlog"
["toggle_ssh_lastlog,desc"]="Toggle SSH lastlog"
["toggle_ssh_lastlog,example"]="toggle_ssh_lastlog"
["toggle_ssh_lastlog,status"]="Active"
)
#
# @description Toggle SSH lastlog
#
function toggle_ssh_lastlog() {
if ! grep -q '^#\?PrintLastLog ' "${SDCARD}/etc/ssh/sshd_config"; then
# If PrintLastLog is not found, append it with the value 'yes'
echo 'PrintLastLog no' >> "${SDCARD}/etc/ssh/sshd_config"
srv_restart ssh
else
# If PrintLastLog is found, toggle between 'yes' and 'no'
sed -i '/^#\?PrintLastLog /
{
s/PrintLastLog yes/PrintLastLog no/;
t;
s/PrintLastLog no/PrintLastLog yes/
}' "${SDCARD}/etc/ssh/sshd_config"
srv_restart ssh
fi
}