When the Junos Shell Stops Responding...
I spent a decent portion of one day this week angrily screaming at the screen.
I couldn’t do anything. I was logged into a switch, and I could type commands
that don’t actually do anything. I could enter
configure mode, I could
even stage changes, but I just couldn’t seem to commit them. The Junos shell
would hang every time. Obviously, this can create all sorts of problems, such
as exhausting the number of SSH connections allowed. I couldn’t even force
logout a user via the Junos shell! To continue troubleshooting, this is what
- Login as
clito start the Junos shell.
- Attempt to troubleshoot.
- When the shell inevitably locks during the troubleshooting process:
^z(control-z) to suspend the shell process.
- Once in the shell, enter the following:
That’s a bit verbose, so I made it into a script that I dropped into root’s directory on all of my devices. Now, I just type
sh kill_cliand POOF! Magic!
Here’s the script I drop into the root folder:
Just make it executable (
chmod 700 kill_cli) and then execute it by typing
Be warned that this method will kill all of the Junos shells, including your peers’! You’ll need to be a bit more selective if you just want to kill your own (i.e., type
ps aux | grep cli | grep -v grep[which can be done from the
cshBSD shell that root uses by default] and hunt down the PIDs [number in the second column] for your user)
Remember I mentioned that you can exhaust SSH connections? Here’s how you can force a user to disconnect from the FreeBSD shell:
tyler above with the login name of the user you wish to
disconnect. You can also just omit
SSH_USER and replace
with the user name (
tyler, in our example).
This is another good candidate for a script!
First, scp the script to the root user’s
$HOME directory. Make it
Finally, execute it with
sh logout_user $SSH_USER, replacing
the user you want to kick out (such as
This post is part of the #30in30 challenge.