Skip to main content

A Django plugin that allows ssh remote tunnels.

Project description

django-ssh-tunnel-proxy

Opens an ssh tunnel so your local development server can be accessed remotely

Quick start

  1. Install with pip install django-ssh-tunnel-proxy
  2. Add sshtunnelproxy to INSTALLED_APPS
  3. Set the settings described below
  4. Start a dev-server using python manage.py runserver
  5. Open a tunnel using python manage.py opensshtunnelproxy
  6. Visit the URL displayed in your terminal

Context manager

Create a temporary tunnel using the context manager

from sshtunnelproxy import tunnel

with tunnel() as remote_url:
    pass  # do something

Available settings

SSH_TUNNEL_USER: str = ''
"""The SSH user to use for the tunnel. default: `''`"""

SSH_TUNNEL_PASSWORD: str = ''
"""The SSH password to use for the tunnel. default: `''`"""

SSH_TUNNEL_PORT_RANGE: tuple[int, int] = (24000, 24999)
"""The range of ports to use for the tunnel. default: `(24000, 24999)`"""

SSH_TUNNEL_HOST: str = ''
"""The host to tunnel to. default: `''`"""

SSH_TUNNEL_URL_GENERATOR: Callable[[int], str] = lambda port: f"http://{SSH_TUNNEL_HOST}:{port + 1}"
"""
The function to generate the tunnel URL.
Takes the remote port as an argument and returns the URL at which the tunnel can be accessed.
default: `lambda port: f'http://{HOST}:{port + 1}'`
"""

Remote server

For this to work, you need a remote web server to reverse-proxy the tunneled port.

What else

Make sure to add SSH_TUNNEL_HOST to your ALLOWED_HOSTS.
Also, SESSION_COOKIE_SECURE = False must be set, or else you won't be able to log in.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_ssh_tunnel_proxy-1.0.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_ssh_tunnel_proxy-1.0.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file django_ssh_tunnel_proxy-1.0.4.tar.gz.

File metadata

  • Download URL: django_ssh_tunnel_proxy-1.0.4.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.4.tar.gz
Algorithm Hash digest
SHA256 9801ade1cc4f5e5278d71b83592bce29e9371f8d94b0ccfae581f78ea7761114
MD5 6be67fb2d61974cba2147d30a530bca3
BLAKE2b-256 51f73fa5cdec221f2b929fd25e5c04d98b2dfad02f59b3850a0e4e37821cf223

See more details on using hashes here.

File details

Details for the file django_ssh_tunnel_proxy-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a57a1d10d9903add5f377ea64e7155418c74bfcb49478b03f004dbbe576d5818
MD5 e49f6373063fdbb5e691ced51c4132a9
BLAKE2b-256 083825d99ca4dda547ef88e84418cfacc6d3b67679e2dbf968983591811e72c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page