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. Set the settings described below
  3. Start a dev-server using python manage.py runserver
  4. Open a tunnel using python manage.py zeromigrations opensshtunnelproxy
  5. 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

USER: str = getattr(settings, "SSH_TUNNEL_USER", "")
"""The SSH user to use for the tunnel. default: `''`"""

PASSWORD: str = getattr(settings, "SSH_TUNNEL_PASSWORD", "")
"""The SSH password to use for the tunnel. default: `''`"""

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

HOST: str = getattr(settings, "SSH_TUNNEL_HOST", "")
"""The host to tunnel to. default: `''`"""

URL_GENERATOR: Callable[[int], str] = getattr(
    settings, "SSH_TUNNEL_URL_GENERATOR", 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.0.tar.gz (4.7 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.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_ssh_tunnel_proxy-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 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.0.tar.gz
Algorithm Hash digest
SHA256 4972b633c412365ae52e5efa66af5bd4e715a5d46b65efd3d3826b1b52c91d27
MD5 d0e3feebbe400deb0ef6d13175a5c64a
BLAKE2b-256 cde2bcc91df3d348aa7706a551f9f6ac882a97581d675051f524295e9ec148fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7778799ae784b0ee73a92cd449a3a1e1f8f10bc532a93d266a7dab3ca39eb7e
MD5 8423b4068b8297a729d13144049cd60b
BLAKE2b-256 61b7efb6ca2a42140dff03b88022710a9ede861e42b8d2c09960e0b9baa206f8

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