20  SSH Port Forwarding

Q: What does this do?
ssh -L 8787:localhost:8787 kittipos@10.6.23.178

This command creates an SSH tunnel (also called port forwarding) to a remote server. Let me break it down:

ssh -L 8787:localhost:8787 kittipos@10.6.23.178

What each part means: - ssh - SSH client command - -L - Local port forwarding flag - 8787:localhost:8787 - Port mapping specification - kittipos@10.6.23.178 - Username and remote server IP

How it works:

Your Mac (Local)          Remote Server (10.6.23.178)
┌─────────────────┐      ┌──────────────────────────┐
│                 │      │                          │
│ localhost:8787  │◄────►│ localhost:8787           │
│                 │ SSH  │ (RStudio Server?)        │
│                 │Tunnel│                          │
└─────────────────┘      └──────────────────────────┘

What this does: 1. Forwards your local port 8787 to port 8787 on the remote server 2. Any connection to localhost:8787 on your Mac gets tunneled through SSH to the remote server’s port 8787 3. The remote service (likely RStudio Server, which commonly uses port 8787) becomes accessible locally

Practical use: You can now open your browser and go to http://localhost:8787 to access what’s running on port 8787 of the remote server - probably RStudio Server for R development.

This is particularly useful when the remote server’s port 8787 isn’t directly accessible from the internet but you have SSH access to the server.