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.1.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.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_ssh_tunnel_proxy-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 280b81859962ee79b7a16a836a034dd2b9ae91fb7232218ec90c621e81807acd
MD5 522a5ac128cc859f7596554b89b99dee
BLAKE2b-256 f80cdab7d414ffd2a6d0b68ceadd4a38bc24a62e2e8ff96e11372927d6b83458

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5eda904f96504d5b993779c59b7ec7b45f3d32c12e6028fe0b8f56773da6b3ed
MD5 7d682a42771b68f8fea5dcc37420954a
BLAKE2b-256 3c540151373596d4923fafe0b8d7870246d2203c4ebdf169db75ed79d665e834

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