diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index 2fb046c2..94e4b267 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -214,7 +214,33 @@ "src_reference": "", "author": "Igor Pecovnik", "condition": "grep -q '^ChallengeResponseAuthentication yes' /etc/ssh/sshd_config && [ -f /root/.google_authenticator ]" - } + }, + { + "id": "S30", + "description": "Disable last login banner", + "command": [ + "sed -i \"s/^#\\?PrintLastLog.*/PrintLastLog no/\" /etc/ssh/sshd_config" , + "systemctl restart ssh.service " + ], + "status": "Active", + "doc_link": "", + "src_reference": "", + "author": "", + "condition": "grep -q '^PrintLastLog yes' /etc/ssh/sshd_config" + }, + { + "id": "S31", + "description": "Enable last login banner", + "command": [ + "sed -i \"s/^#\\?PrintLastLog.*/PrintLastLog yes/\" /etc/ssh/sshd_config" , + "systemctl restart ssh.service " + ], + "status": "Active", + "doc_link": "", + "src_reference": "", + "author": "", + "condition": "grep -q '^PrintLastLog no' /etc/ssh/sshd_config" + } ] }, { diff --git a/lib/armbian-configng/config.ng.system.sh b/lib/armbian-configng/config.ng.system.sh index 4c54cbb8..9ef446e3 100644 --- a/lib/armbian-configng/config.ng.system.sh +++ b/lib/armbian-configng/config.ng.system.sh @@ -175,4 +175,34 @@ if [[ "$1" == "enable" ]]; then fi # reboot is mandatory reboot +} + + +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" + sudo service ssh restart +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" + sudo service ssh restart +fi + } \ No newline at end of file