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

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_ssh_tunnel_proxy-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 aaf100ed7a04e2d92b3a534b86876b850f9dd4fae70d7b2b10a1a0eb7dfb7803
MD5 a8eafd053bbd8f6bcb1bec4495c57deb
BLAKE2b-256 e196ee177d1e35ba1c89a2aabf1179f2310dd6e8f9af9cc7bd420f25afca2b66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_ssh_tunnel_proxy-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c3b3c827d94fbf2322b505c79f2fd914e5507b02112d9ed958b74627023abc83
MD5 ba4b7e634cad0b9eb0ce03611902dd6a
BLAKE2b-256 e15117d2f380d38e886e664babdc63bf703aec3a6dababc94d05ddce28f157c5

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