KB Article #179321

Number of concurrent SSH connections

Problem

How can one find the number of concurrent SSH connections to the SecureTransport's SSH service?


Resolution

Out of the box, SecureTransport does not offer such functionality. The Server Usage monitor after ST 5.4.0 will give you a combined list of users, which are currently using ST over HTTP, FTP and SSH so if you are after the total number of SSH sessions, you can't find in ST's Admin UI.


What you could do is execute the below command on the command line interface of all SecureTransport servers that are accepting SSH connections(i.e. SecureTransport servers that have their SSH service running). Here is the command:


Linux/UNIX

netstat -an | grep '\S\:22\s' | grep ESTABLISHED | wc -l


Windows (Powershell)

netstat -an | findstr :22 | findstr ESTABLISHED | Measure-Object –Line


However, due to the netstat based command on Windows matching port "2200" when we search for port 22, we can use the built-in Get-NetTCPConnection Powershell cmdlet that serves as a powerful alternative to netstat.


Get-NetTCPConnection | ? {( $_.State -eq "Established") -and ($_.LocalPort -eq "22")} | Measure-Object –Line


Note that the above command would work for the default SSH port 22. If you are using a different port for the SSH service, you could simply change the "22" to the port number that you use.