I open an SSH tunnel (for port forwarding) from Windows 10 PC to a remote Linux server by typing the following command in Windows Command Prompt:

(Note: substitute the actual DNS for host_IPv4_public_DNS)

C:> ssh -i thekey.pem -N -f -L 8888:localhost:8888 host_IPv4_public_DNS

After executing this command the tunnel opens, it is fully functional. The issue is that I don't get the windows command prompt (C:>) back. The process keeps running. How do I terminate this process/tunnel?

  • 2
    The same command on Unix/Linux would fork after auth and give back a command prompt. But you are using Windows.
    – A.B
    Mar 3, 2021 at 16:39

1 Answer 1


Remove the -N from your command that is telling ssh not to execute a command

 -N      Do not execute a remote command.  This is useful for just forwarding ports.

ssh -i thekey.pem -f -L 8888:localhost:8888 host_IPv4_public_DNS

Would be your command now if you want to have access to the remote host if you want access to your host cmd. I would run

start /b ssh -i thekey.pem -f -L 8888:localhost:8888 host_IPv4_public_DNS

That will open the connection in the background you can kill the process after using CTRL + BREAK

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.