- In the "dead" terminal, where you started the
ssh -N ...
you can just press Ctrlc to cancel the ssh
process.
- If you sent it to the background get the job back to the foreground to send it a
^C
.
# At the client system:
# To find it:
jobs
[1]+ Running ssh -N -R53407:localhost:53407 user@server &
# To bring to foreground:
fg 1
# To cancel:
^c
- Else find the ssh process in your task list, get its process-id (PID) and execute:
kill <PID>
Using kill
like this is not an assassin at work but more like a nice postman that hands out the message to ssh
to quit itself properly. — So give ssh some seconds to do the quit-job.
Preferably you should check the open ports by ss
:
# At the remote system:
sudo ss -tanp | grep "sshd"
This will also help, when you are local at the server to terminate the ssh connection:
# Alternatively at the server:
sudo ss -tanp | grep ":53407"
LISTEN 0 128 127.0.0.1:53407 0.0.0.0:* users:(("sshd",pid=247750,fd=9))
LISTEN 0 128 [::1]:53407 [::]:* users:(("sshd",pid=247750,fd=8))
# Get the PID from the output and send the kill command:
kill 247750
Note: Other sshd connections will not quit, as sshd
forks for each connection, so using a different PID for each of them.
lsof
that looks like it has been invoked on the server, but we cannot be sure until you tell us. (3) To terminate port forwarding set up byssh -N ...
usually you just need to kill thessh
process. Did you do that? Is the issue becausesshd
did not notice?