View and Check Who Login on SHH Server

 

View and Check Who Currently Login on SHH Server

 

   The step by step using lsof command to view or check who currently login on SSH server.  The step by step article below show the the example using the lsof command on Linux Fedora sever to view and check who currently login on SHH server.  Please note that the default setting for SSH server usually listen on port 22, make sure that you edit the port number if you customize the SHH server setting. 

 

To start check SHH server connection, or who is currently login on our Linux Fedora server using SSH connection.. execute command as show on example below.

 

check SSH connection using port number:

View and Check Who Currently Login on SHH Server

[root@fedora ~]# lsof -i :22

COMMAND   PID   USER   FD   TYPE DEVICE SIZE NODE NAME

sshd     1892   root    3u  IPv6   4966       TCP *:ssh (LISTEN)

sshd     1892   root    4u  IPv4   4968       TCP *:ssh (LISTEN)

sshd    14382   root    3r  IPv4  56404       TCP 172.16.162.125:ssh->172.16.162.60:directvdata (ESTABLISHED)

sshd    14519   root    3r  IPv4  59072       TCP 172.16.162.125:ssh->172.16.162.60:wg-netforce (ESTABLISHED)

sshd    14522 fedora    3u  IPv4  59072       TCP 172.16.162.125:ssh->172.16.162.60:wg-netforce (ESTABLISHED)

[root@fedora ~]#

 

or you also can view or check SSH connection using name:

view or check SSH connection using ssh service name

[root@fedora ~]# lsof -i :ssh

COMMAND   PID   USER   FD   TYPE DEVICE SIZE NODE NAME

sshd     1892   root    3u  IPv6   4966       TCP *:ssh (LISTEN)

sshd     1892   root    4u  IPv4   4968       TCP *:ssh (LISTEN)

sshd    14382   root    3r  IPv4  56404       TCP 172.16.162.125:ssh->172.16.162.60:directvdata (ESTABLISHED)

sshd    14519   root    3r  IPv4  59072       TCP 172.16.162.125:ssh->172.16.162.60:wg-netforce (ESTABLISHED)

sshd    14522 fedora    3u  IPv4  59072       TCP 172.16.162.125:ssh->172.16.162.60:wg-netforce (ESTABLISHED)

[root@fedora ~]#

 

Troubleshoot:

 

1.  If you cannot execute the lsof command and show "-bash: lsof: command not found" error, as show on example below

[fedora@fedora ~]$ lsof -i :22

-bash: lsof: command not found

[fedora@fedora ~]$

 

2.  You may need to log in as root user or use the su command as show on example below and supply the root user password when ask...

 

[fedora@fedora ~]$ su - -c "lsof -i :22"

Password:

[fedora@fedora ~]$

 

3.  or

 

[fedora@fedora ~]$ su - -c "lsof -i :ssh"

Password:

[fedora@fedora ~]$

 

Keywords: who login ssh server, check who login ssh server, check ssh server, check ssh connection, check who currently login on ssh server, view ssh connection 

 

aaaaaaaaaaa