How to cancel local port forward from ssh console
with more recent versions of (open)ssh, there's an escape command to cancel local forwards as well:
ssh> help
Commands:
-L[bind_address:]port:host:hostport Request local forward
-R[bind_address:]port:host:hostport Request remote forward
-D[bind_address:]port Request dynamic forward
-KL[bind_address:]port Cancel local forward
-KR[bind_address:]port Cancel remote forward
-KD[bind_address:]port Cancel dynamic forward
There's no simple way to do it on the command-line.
You can find the PID:
$ ps x | grep ssh
1234 ? Ss 0:00 ssh -f -N -L 8080:localhost:8080 remotehost
And then kill the process:
$ kill 1234