How do I kill a stuck ssh connection without closing the konsole window?

3

I use KDE (with ubuntu) and love using konsole as my terminal. I ssh a lot and every now and then (from various reasons) my connection dies and the sesson is stuck. I need to send a SIGHUP to the terminal so that the ssh session will end and I can use that window again. How do I do that with a keyboard shortcut (I hate being forced to use the mouse for Edit->Send Signal->Hangup).

DrorCohen

Posted 2016-10-06T21:00:46.653

Reputation: 234

If you have only one ssh connection it's enough to do a pkill ssh. If you have more than one you can search for the IP in the top -c ... You may think to pipe the pgrep ssh to build the top -c of only that processes... – Hastur – 2016-10-06T21:42:04.043

2A useful trick in this situation is to type ~. to tell ssh to drop the connection (ssh only looks for it at the beginning of a line so you might have to hit return first). – lemonsqueeze – 2016-10-07T00:40:11.960

@lemonsqueeze - will your suggestion work on a stuck connection? I will try it next time and report? – DrorCohen – 2016-10-07T15:59:05.050

Yes, I use it all the time =) – lemonsqueeze – 2016-10-07T19:14:40.017

@lemonsqueeze: it worked. Thanks! if you'll write it as an answer I'll accept it – DrorCohen – 2016-10-07T20:10:46.203

Answers

0

Thanks for @lemonsqueeze remark - I found a solution.

hit ~. and a stuck ssh will end.

Not KDE related but that's good enough for my purpose.

DrorCohen

Posted 2016-10-06T21:00:46.653

Reputation: 234

2So I am clear... ~. sends a SIGHUP? Or does this answer provide an answer to a different question? – jww – 2019-04-15T18:15:41.547

This doesn't appear to be an answer, why is it accepted? – xaxxon – 2019-07-24T19:03:25.790