This article is about creating a tunnel to a remote server that will be instructed to act as a proxy server.
It only needs
ssh on the local machine, and an
sshd-service on the remote server, which is usually already installed on Linux.
A proxy may be used to access the internet through the remote server's internet connection.
The following command creates a local SOCKS5 proxy to a remote server. This is basically a port to an ssh-tunnel to the remote server, using the SOCKS5 protocol, so that it may use the remote server's internet connection. A local application (such as an internet browser) can make use of this, by configuring the SOCKS5 proxy in the settings of that application. Sometimes a system-wide SOCKS5 proxy is also possible at the network/wifi/ethernet settings.
ssh -D 1337 -q -C -N -p 22 email@example.com
sshis the client program to open an ssh-connection to the server. The server must have the
-D 1337specifies the local bind port, this is what must be configured in the local application or system that uses the proxy.
-qsurpresses verbose output from ssh.
-Cenables compression in order to lower bandwidth at the cost of additional computational power.
-Nis there to say that no command will be passed to execute.
-p 22is redundant if the port is 22, since that is the default. But this option may be used to specify an alternative port on which to connect to the remote sshd service.
firstname.lastname@example.org respectively the username to authenticate, and the domain name at which to connect to the remote sshd service. An IPv4 or IPv6 address may also be used instead of a domain name.
The above command will keep running until interrupted, an error occurred, or it is killed.
To stop the command gracefully, use
In order to make use of the created proxy tunnel, manually configure the application or system like so:
- SOCKS Host:
- SOCKS Port:
- SOCKS Version:
- SOCKS v5
Additionally, you may choose an option to also proxy DNS (Domain Name System) when using SOCKS v5, which is recommended for improving privacy.