This article provides information on how to check the number of current SSH sessions.
At times, when using SSH to logon to a Junos device, the connection fails; even when the IP address is reachable. This may be due to the SSH session limitation being exceeded.
A default SSH session limitation, which has a default value of 75, is present in Junos OS release 12.2. This can be modified via the configuration under the [system – service – ssh – connection-limit] hierarchy.
If the number of the current SSH sessions (including the active and stale sessions) is equal to the maximum limitation, a new SSH session will not be established.
Even though it is possible to display the number of active sessions being carried by the chassis, (via the show system users command), stale sessions might still exist and they cannot be displayed in the output of the command. You can use the following shell command to check how many SSH sessions are currently being carried by the chassis:
% ps aux | grep sshd root 99875 81.1 0.1 6252 2648 ?? Rs 8:15PM 2:17.92 sshd: test@notty (sshd) root 79158 0.0 0.1 6096 2540 ?? Is 4:34PM 0:00.02 sshd: test@notty (sshd) root 79250 0.0 0.1 6096 2540 ?? Is 4:34PM 0:00.02 sshd: test@notty (sshd) root 79307 0.0 0.1 6096 2540 ?? Is 4:34PM 0:00.02 sshd: test@notty (sshd) root 79366 0.0 0.1 6096 2540 ?? Is 4:34PM 0:00.02 sshd: test@notty (sshd) root 79710 0.0 0.1 6096 2540 ?? Is 4:35PM 0:00.02 sshd: test@notty (sshd) <snipped>
Each sshd line represents one SSH session. By checking the result, you can tell how many SSH sessions are being carried by this chassis. To release some of these SSH sessions, use the kill command to terminate them by using the corresponding PID:
%kill -9 PID
By releasing some of the existing (possibly stale) SSH sessions, new SSH sessions can be successfully established.