Create a restricted Bash user with with activity logging on linux system
This project demonstrates how to create a limited Bash shell user (rbash) in Linux, log their commands to /var/log, and ensure security by restricting shell access.
Features:
-Restricted shell ("rbash")
- Command logging using("script")
- Secure logging storage in "/var/log"
- Easy setup
Setup
sudo useradd -m -s /usr/bin/rbash desmondkrus # replace with your own namesudo touch /var/log/desmondkrus_session.log
sudo chown desmondkrus:desmondkrus /var/log/desmondkrus_session.log
sudo chmod 600 /var/log/desmondkrus_session.logsudo bash -c 'cat <<EOF > /usr/local/bin/logrbash
#!/bin/bash
LOGFILE="/var/log/desmondkrus_session.log"
exec /usr/bin/script -q -f -c "/bin/rbash" "$LOGFLE"
EOF'After that run these commands
sudo chmod +x /var/log/bin/logrbash
sudo usermod -s /usr/local/bin/logrbash desmond
krusLogin as the restricted User:
su - desmondkrus
pwd
whoami
exitVerify the logged activity
sudo cat /var/log/desmondkrus_session.logLicense This project is license under the MIT license
Author Harison Kimutai Chirchir harisonchirchir25@gmail.com