# Local port forwarding.
# With this example we forward port 80 to 8080.
# Example:
ssh -L 8080:192.168.1.50:80 user@192.168.1.50

SSH Port Forward Ollama

SSH port forwarding for Ollama allows you to access the Ollama service running on a remote server from your local machine. This is typically done using the -L option in the ssh command, which forwards a local port to a remote port. For example, to forward port 11434 (the default port for Ollama) from the remote server to your local machine, you can use the following command:

ssh -L 11434:localhost:11434 remote
This command sets up a tunnel so that when you access http://localhost:11434 on your local machine, it is equivalent to accessing the Ollama service on the remote server.

If you want to forward multiple ports, you can specify the -L option multiple times. For instance, to forward both port 5900 and 11434, you would use:

ssh -L 5900:localhost:5900 -L 11434:localhost:11434 remote
Additionally, you can simplify the command by using the SSH configuration file (~/.ssh/config). This file allows you to define aliases and set up port forwarding rules. For example, you can define a host entry that includes the port forwarding configuration:

Host mytunnel   User myuser   Hostname 192.168.1.42   LocalForward 11434 localhost:11434
With this configuration, connecting to mytunnel will automatically set up the port forwarding.

If you are using a tool like Open WebUI, you might need to ensure that the Ollama service is accessible locally. This can be achieved by setting up an SSH tunnel to forward the necessary ports. For example, to forward port 11434, you can use:

ssh -fNT -L 11434:172.17.0.2:11434 remote_host
This command ensures that the Ollama service running on the remote host is accessible on your local machine through the specified port.