Skip to content

Commit

Permalink
added last login toggle (#82)
Browse files Browse the repository at this point in the history
Co-authored-by: Tearran <[email protected]>
  • Loading branch information
Tearran and Tearran authored Sep 16, 2024
1 parent c5d45ae commit 9b27cb8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/armbian-configng/config.ng.jobs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
},
{
Expand Down
30 changes: 30 additions & 0 deletions lib/armbian-configng/config.ng.system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

0 comments on commit 9b27cb8

Please sign in to comment.