Set up the tunnel with this command:
ssh -i ~/.ssh/id_rsa -D 2345 -f -C -q -N ja@peerend
Explanation of arguments:
-i: The path to the SSH key to be used to connect to the host
-D: Tells SSH that we want a SOCKS tunnel on the specified port number (you can choose a number between 1025 and 65536)
-f: Forks the process to the background
-C: Compresses the data before sending it
-q: Uses quiet mode
-N: Tells SSH that no command will be sent once the tunnel is up
Client script
socks.sh
#!/bin/bash -e
ssh -i ~/.ssh/id_rsa -D 2345 -f -C -q -N ja@peerend
/usr/bin/firefox &
SOCKS performs at Layer 5 of the OSI model. A SOCKS server accepts incoming client connection on TCP port 1080.