Forum Discussion
Execute a shell script prior to full login
Anyone know of a way to initiate a script during ssh login? I have a requirement to provide users with their failed login count, from a remote authentication server, upon successful logon. I have a ldapsearch script that executes once a user logins in but since they just successfully authenticated to the authentication server their badPwdCount is always zero.
I've been looking at ssh_config but I can't find a way to make it initiate a shell script.
3 Replies
- samstep
Cirrocumulus
You should be able do this the same way you would do on a Linux machine - add your script as a .sh file on /etc/profile.d/ folder.
For example I created this bash script : myscript.sh in folder /etc/profile.d/ and made it executable using
chmod +x /etc/profile.d/myscript.shmyscript.sh has contents:
echo "Last Failed login attempt:" aureport --login --failed|grep ${USER}|tail -1now when users ssh to the box they will see their last failed login attempt
Obviously you can use any other valid commands in your bash script and name it differently. Note that since you are modifying the base operating system config this will not be supported by F5 and can be potentially overwritten during the upgrades.
Hope this helps,
Sam
- JPrice_230829
Nimbostratus
Thanks, I've never used the aureport command before. With some help from a coworker this is what I ended up with: startday=$( aureport -au | tail -2 | head -1 | awk '{print $2}' ) starttime=$( aureport -au | tail -2 | head -1 | awk '{print $3}' ) failcount=$(aureport -au --start $startday $starttime | grep $USER | grep no | wc -l) echo "Failed login attempts since your last successful login: ${failcount}" - JPrice_230829
Nimbostratus
With some help form a coworker this is what I ended up with:
startdate=$( aureport -au | tail -2 | head -1 | awk '{print $2}' ) starttime=$( aureport -au | tail -2 | head -1 | awk '{print $3}' ) failcountt=$(aureport -au --start $startdate $starttime | grep $USER | grep no | wc -l) echo "Failed login attempts since your last successful login: ${failcount}"
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
