A team wants to know who is logged in and from where on a server right now and historically. Which commands?
BeginnerScenarioNetworking, SSH and remote access
Answer
Situation read → Session accounting files plus auth logs.
What I'd do →
w # current sessions and what they're running
who -a
last -F -n 20 # history from /var/log/wtmp
lastb | head # failed logins from /var/log/btmp
journalctl -u sshd --since today | grep Accepted
Why → wtmp holds logins, btmp failed attempts and the journal has the key fingerprint used.
Interview tip → Note that an attacker with root can edit these files, so ship them off-box.
More on Networking, SSH and remote access
A key belonging to a departed engineer may be in `authorized_keys` on 300 servers. How do you rotate SSH keys across the fleet?IntermediateYou need to reach a database on a private subnet from your laptop through a bastion. How?BeginnerYour security team wants SSH hardened on all servers. What changes do you make?BeginnerA new server needs a static IP, gateway and DNS on RHEL 9. How do you configure it persistently?BeginnerYou're changing the network config of a remote server over SSH and could lose access. How do you protect yourself?IntermediateA web server should accept HTTP/HTTPS from anywhere but SSH only from the office. Configure the firewall.Beginner