Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added last login toggle #82

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

}
Loading