0Pricing
Linux Server Deployment & SSH Mastery · Lesson

SSH Tunnels and SOCKS Proxy

Create secure SSH tunnels for encrypted communication and set up a SOCKS proxy for anonymous browsing or bypassing network restrictions.

SSH Tunnels and SOCKS Proxy is a free Linux Server Deployment & SSH Mastery lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Linux Server Deployment & SSH Mastery learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Introduction to SSH Tunnels

Welcome to SSH Tunnels! These aren't physical tunnels, but secure connections that let you forward network traffic through an SSH server.

Think of it as creating a secret, encrypted pathway through a public network. This pathway lets you access services that might otherwise be blocked or insecure.

Why Use SSH Tunnels?

SSH tunnels are incredibly versatile for developers and system administrators. They help you:

  • Bypass Firewalls: Access internal services not exposed to the public internet.
  • Secure Unencrypted Traffic: Encrypt data that would normally travel insecurely (like old protocols).
  • Access Restricted Resources: Reach services on a private network from a public one, or vice-versa.

Local Port Forwarding Explained

Local Port Forwarding is when you connect a port on your local machine to a port on a remote machine (via the SSH server).

The SSH server acts as a middleman. Your local application connects to a local port, and SSH securely forwards that traffic to the specified remote host and port.

Local Forwarding: The Command

The syntax for local port forwarding is straightforward:

ssh -L [local_port]:[remote_host]:[remote_port] [user]@[ssh_server]

Here's an example to access a database running on db-server (port 3306) through your ssh-gateway server:

ssh -L 8080:db-server:3306 user@ssh-gateway.com

Local Forwarding: Practical Use

After running the command from the previous scene, you can now connect your local database client to localhost:8080.

All traffic you send to localhost:8080 will be securely forwarded through ssh-gateway.com to db-server:3306. This is great for accessing private databases or web services.

Remote Port Forwarding Explained

Remote Port Forwarding is the opposite of local forwarding. It allows you to expose a service running on your local machine to a port on the remote SSH server.

This means others can connect to a port on the remote SSH server, and their traffic will be forwarded securely to your local service.

Remote Forwarding: The Command

The syntax for remote port forwarding uses the -R flag:

ssh -R [remote_port]:[local_host]:[local_port] [user]@[ssh_server]

Let's say you have a web server running locally on port 8000 and want to make it accessible to others via your ssh-gateway on port 8888:

ssh -R 8888:localhost:8000 user@ssh-gateway.com

Remote Forwarding: Practical Use

Once the remote tunnel is established, anyone who can reach ssh-gateway.com can now access your local web server by connecting to ssh-gateway.com:8888.

This is useful for sharing a local development server with teammates or for webhooks that need to reach your local machine.

SOCKS Proxy via SSH

A SOCKS proxy allows you to route all your application's traffic (e.g., web browser, chat client) through the SSH server. This is often used for anonymizing browsing or bypassing network restrictions.

The -D flag creates a SOCKS proxy on a local port:

ssh -D 9999 user@ssh-gateway.com

Configuring Your Client for SOCKS

After running ssh -D 9999 user@ssh-gateway.com, you'll have a SOCKS proxy running on localhost:9999.

You then configure your web browser (or other application) to use localhost as a SOCKS5 proxy on port 9999. All your internet traffic from that application will now be routed securely through your ssh-gateway.

Tunnel Vision Check

You're trying to access a private internal web service running on internal-app.local:80 from your local machine (localhost). You have SSH access to jump-host.com.

Which SSH command would you use to forward local port 8080 to the internal web service?

Tunnels & Proxies Summary

You've mastered SSH tunnels! We covered:

  • Local Port Forwarding (-L): Access remote services from your local machine.
  • Remote Port Forwarding (-R): Expose local services to the remote SSH server.
  • SOCKS Proxy (-D): Route all application traffic through the SSH server for privacy or bypass.

These techniques are powerful tools for secure and flexible network access in development and administration.

Frequently asked questions

Is the “SSH Tunnels and SOCKS Proxy” lesson free?

Yes — the full text of “SSH Tunnels and SOCKS Proxy” is free to read here on the web, and the Linux Server Deployment & SSH Mastery course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Linux Server Deployment & SSH Mastery course, upgrade to CoddyKit PRO.

What will I learn in “SSH Tunnels and SOCKS Proxy”?

Create secure SSH tunnels for encrypted communication and set up a SOCKS proxy for anonymous browsing or bypassing network restrictions. You practise Linux Server Deployment & SSH Mastery with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Linux Server Deployment & SSH Mastery?

No prior experience is required. Linux Server Deployment & SSH Mastery on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “SSH Tunnels and SOCKS Proxy” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Linux Server Deployment & SSH Mastery lesson?

Yes. Every Linux Server Deployment & SSH Mastery lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. SSH Port Forwarding (Local/Remote)
  2. SSH Tunnels and SOCKS Proxy
  3. SSH Agent and Multi-hop
  4. Secure File Transfer with SCP, SFTP, and rsync
← Back to Linux Server Deployment & SSH Mastery