I've used the command ssh -D 8080 -f -C -q -N user@IP to SSH into a VPS and set it to browse in the SOCKS proxy settings in System Preferences (on my Mac).

How do I cancel the SSH session (and browse normally) without having to log out?

I know Ctrl+C 'cancels' certain commands that are running, but once I do the ssh -D it immediately logs out of the VPS.

Also, unrelated question: Does logging out cancel the SSH 'binding' on the port?

1 Answer 1


It seems you are asking two or three questions.

To use ssh to tunnel, I advise you start a non-interactive session

ssh -C2qTnN -D 8080 user@IP

That will put the ssh tunnel in the background.

Use the proxy: You then configure your browser or system settings to use the proxy on localhost port 8080.

Stop using the proxy: You then re-configure your system to not use the proxy (undo the above step).

To end the ssh session,

killall ssh

Or kill the process by process id

I usually run a separate ssh session if you wish to enter commands on the server.

See also https://calomel.org/firefox_ssh_proxy.html


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.