This is in reference to this question.
I wanted to log everytime someone logged in via ansible.
I put my script in
~/.bash_profile file. Here is the script,
#!/bin/bash now=$(date +"%T") echo "$USER logged in at: $now" >> /home/alphauser/ssh-entries.log
I put this at the end of
However, ansible uses the non-interactive shell, so my script was not executed when I logged in via ansible as
~/.bash_profile is executed only when a new interactive shell is started.
Then I pasted this at the end of
.bashrc file, but still it did not work.
How can I log entries when someone logs in via non-interactive shell ? I mean where should I place this script so that it should be executed everytime someone logs in via ansible ?
I hope the question is clear.