To solve the immediate problem, that the sudoers file is locked, you can simply delete the lock file. It will usually be `/etc/sudoers.tmp"; check the man page for visudo to verify. If you delete the lock file, you can run visudo again.
To delete all sessions which are still left hanging, first find out the pid of your own current session. Then, if your own pid is 12345, do
ps -ef | grep sshd | grep -v -e grep -e root -e 12345 | awk '{print "sudo kill -9", $2}' | sh
You may want to do it without the final | sh
first just to check the PIDs you're planning on killing.
If you're on Linux, you can instead use
pkill -o -u $USER sshd
to kill your oldest SSH session. Continue doing that until your current session is the only one left.
You might also want to set ServerAliveInterval 15
in your .ssh/config
to send a keepalive message every 15 seconds when no data has been sent. man ssh_config
for more information.
fuser -k /dev/pts/0
or whatever terminal's showing up in thewho
output. A little weird all those ignored SIGHUP, though. Were they running in ascreen
session or something? – Bratchley May 02 '14 at 13:46who
anymore), thanks! – markmnl May 02 '14 at 13:54