I created a forward only ssh connection with the following:

ssh -i id_rsa -o TCPKeepAlive=yes -o ServerAliveInterval=10  \ 
    -N -n -R [email protected]

Mow, on the server, I would like to disconnect that connection. If the user is connected with a shell session then pkill works but if it is a forward only connection, then I can't disconnect.

I tried pkill -u fwd user and it only works if the user has a connection. I tried to look in the list of processes and it does not appear

Does anyone know how to disconnect a forward only connection?

1 Answer 1


It's ssh client that's working on your side (local), not sshd. pgrep -l ssh should list pids and names. If no clue, try netstat -tnp|grep -F ''. Or run lsof [email protected]:8888 and find the pid and kill.

Or ssh into the remote machine, and press ~C and enter on it's own line. You'll get ssh> prompt, type -h for help. ~# lists forwarded connections. Use -KR127.0.0.1:8888 for killing remote forwarding in your case.

  • Thanks for the answer but I actually meant to force disconnection from the server side, not the client side. I have indeed been experimenting with lsof, thanks
    – Youn Elan
    Commented Feb 2, 2015 at 20:59
  • 3
    fuser -kin tcp 8888,, will prompt to kill process accessing local port 8888. Make sure with ps -p $(pgrep -d, sshd) -o args,pid Commented Feb 3, 2015 at 19:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .