who and w not showing sshd users

Status
Not open for further replies.

Visseroth

Guru
Joined
Nov 4, 2011
Messages
546
I recently starting using ssh to transfer files offsite but noticed that who and w does not show users logged in via sshd. Is this normal or is this a bug. I would like to be able to see any and all users logged in to my server and how they are logged in.

Correct me if I'm wrong but shouldn't who and w show a user logged in via sshd
 

warri

Guru
Joined
Jun 6, 2011
Messages
1,193
Hey, I'm using the following script to determine the online users:

Code:
#!/bin/sh
# show all logged in users (sftp)
echo SFTP Users:
fstat | grep internet | grep "sshd" | grep -v "root" | cut -d ' ' -f 1
echo _______________
echo SAMBA Users:
fstat | grep internet | grep "smbd" | grep -v "root" | cut -d ' ' -f 1


I possibly found it somewhere on the forums ehre a while ago..
 

Visseroth

Guru
Joined
Nov 4, 2011
Messages
546
I think it would be nice if who and w did what it was supposed to (not trying to be rude) but one would think that if you wanted to know who was connected or logged into the system that typing "who" or "w" would do just that.
so ok, thanks for the script. I'll add it to my list of scripts I have been adding to my server to see information the gui won't provide.
Thanks again.
 

Visseroth

Guru
Joined
Nov 4, 2011
Messages
546
Any idea on how to kick a user off of sftp?
 

warri

Guru
Joined
Jun 6, 2011
Messages
1,193
I just tested the commands, "who" and "w" both show users logged into ssh. However, they ignore users connected via sftp. But I think this is intended by design, since I found the following forum entry: List of users connected by sftp.:
Connections via sftp aren't considered interactive logins, thus.. are not registered via utmp(5)/wmtp.
Which seems to make sense, since sftp users usually can not login via ssh to an interactive shell.

Therefore you can only use the workaround with an additional script.
 

Visseroth

Guru
Joined
Nov 4, 2011
Messages
546
I don't understand how it makes sense. It makes sense to know who is connected to your machine when typing who or w.
Any good admin would want to know who is connected and how they are connected. Specially on a server that is serving to the www that is supposed to have tight security and limited connections.
I understand that sftp is not interactive but they are still connected and active users.
Anyhow, that is my thought.
Still thanks a ton for the script, it definitely works.
 
Status
Not open for further replies.
Top