Nathan
Nathan

Reputation: 78439

Tunneling a local command through SSH

What is the best way to run a command through an ssh tunnel? Not running the command on the remote server, but forwarding locally created traffic to it through a tunnel.

For example, wget. How can I run wget on my local machine so that it tunnels to a VPS that I have ssh access to? Both the local and remote servers are running Arch Linux.

Upvotes: 2

Views: 1879

Answers (1)

Mark Nicolle
Mark Nicolle

Reputation: 317

From what i got, your question is about a proxy, specifically, a socks proxy . So the easiest way to do this is to show you some examples. and work from that.

ssh -NT -D 1080 [email protected]

What this is doing is keeping the port 1080 open as a socks5 proxy -NT keeps the connection alive. Then what needs to be done is to use the proxy. I dont think wget has the option to use a socks proxy so we will have to use curl as i know that can use them.

curl -O  --socks5-hostname 127.0.0.1:1080 url 

This connects to the socks proxy and downloads from url.

Upvotes: 1

Related Questions