Skip to main content
**Author**: Pahaz Blinov
**Repo**: https://github.com/pahaz/sshtunnel/


Inspired: https://github.com/jmagnusson/bgtunnel but it don`t work on windows.
See also: https://github.com/paramiko/paramiko/blob/master/demos/forward.py

Require `paramiko`.

# Install #

pip install sshtunnel

or

easy_install sshtunnel

# SSH tunnels to remote server #

Useful when you need to connect to local port on remote server throw ssh
tunnel. It works by opening a port forwarding ssh connection in the
background, using threads. The connection(s) are closed when explicitly
calling the `close` method of the returned SSHTunnelForwarder object.

----------------------------------------------------------------------

|
-------------| | |----------| |---------
LOCAL | | | REMOTE | | PRIVATE
SERVER | <== SSH ========> | SERVER | <== local ==> | SERVER
-------------| | |----------| |---------
|
FIREWALL

----------------------------------------------------------------------

Fig1: How to connect to PRIVATE SERVER throw SSH tunnel.


## Ex 1: ##

import sshtunnel

with sshtunnel.open(
(ssh_host, ssh_port),
ssh_host_key=None,
ssh_username=ssh_user,
ssh_password=ssh_password,
ssh_private_key=None,
remote_bind_address=(REMOTE_HOST, REMOTE_PORT)) as server:

def do_something(port):
pass

print "LOCAL PORT:", server.local_bind_port

do_something(server.local_bind_port)

## Ex 2: ##

from sshtunnel import SSHTunnelForwarder

server = SSHTunnelForwarder(
ssh_address=('pahaz.urfuclub.ru', 22),
ssh_username="pahaz",
ssh_password="secret",
remote_bind_address=('127.0.0.1', 5555))

server.start()

print(server.local_bind_port)
# work with `SECRET SERVICE` throw `server.local_bind_port`.

server.stop()

# AUTHORS #

- [Pahaz Blinov](https://github.com/pahaz)
- [Cameron Maske](https://github.com/cameronmaske)
- [Gustavo Machado](https://github.com/gdmachado)

# CHANGELOG #

## work in progress ##
- add `threaded` options (cameronmaske)
- fix exception error message, correctly printing destination address (gdmachado)

## v.0.0.1 ##
- `SSHTunnelForwarder` class (pahaz)
- `open` function (pahaz)

Metadata

Release files for sshtunnel 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for sshtunnel 0.0.2
File Interpreter ABI Platform
sshtunnel-0.0.2-py2.7.egg Legacy Egg format - - Details

Release files / sshtunnel-0.0.2-py2.7.egg

Download URL sshtunnel-0.0.2-py2.7.egg
Size 8.5 kB
Tags Egg
SHA-256 checksum
How to use checksums
1ac6196512ad8ca43830737b75e6ab748af7f67f3a9660299895dadac54f66b5
BLAKE2b-256 checksum
How to use checksums
eecf8094f8d7ae7c6e253940af7f1b6e882a3bfd0a864b161cd38f8725af4198
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.5.1

2 release files

0.4.0

3 release files

0.3.2

3 release files

0.3.1

3 release files

0.3.0

3 release files

0.2.2

3 release files

0.2.1

3 release files

0.2.0

3 release files

0.1.5

8 release files

0.1.4

1 release file

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

1 release file

0.0.8.2

1 release file

0.0.8.1

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

2 release files

0.0.5

1 release file

0.0.4.4

1 release file

0.0.4.3

1 release file

0.0.4.2

1 release file

0.0.4.1

1 release file

0.0.4

1 release file

0.0.3

1 release file

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page