Skip to content
KitploitKITPLOIT
उपकरणएक्सप्लॉइटब्लॉग
Log in
जमा करें
उपकरणएक्सप्लॉइटब्लॉग
जमा करें

हैकिंग, पेनटेस्ट और साइबर सुरक्षा उपकरण आपके सुरक्षा शस्त्रागार के लिए!

Kitploit हैकिंग, साइबर सुरक्षा और पेंटेस्टिंग टूल्स की एक निर्देशिका है। कमजोरियों को खोजने, सिस्टम का विश्लेषण करने, परीक्षण को स्वचालित करने और अपनी सुरक्षा को मजबूत करने के लिए नवीनतम प्रोजेक्ट अपडेट खोजें।

फ़ीडसंपर्कगोपनीयता© 2026 Kitploit

टूल निर्देशिका

श्रेणियाँ

सभी श्रेणियाँ देखें
Loading categories
sshtunnel — SSH टनल्स को रिमोट सर्वर पर। | Kitploit
उपकरण/GitHubGitHub/pahaz/sshtunnel
सामान्य उपयोगिताएँनेटवर्क सुरक्षाउपयोगिताएँ और फ्रेमवर्क
GitHubpahaz/sshtunnel

sshtunnel

SSH टनल्स को रिमोट सर्वर पर।

रिपॉजिटरी देखें
1.3k202345 दिन पहलेKitploit द्वारा समीक्षित

सबसे लोकप्रिय

सभी देखें →

हमारे समुदाय द्वारा सबसे अधिक उपयोग किए जाने वाले उपकरण खोजें।

सभी उपकरण खोजें

हमारे उपकरणों का संग्रह ब्राउज़ करें

सभी उपकरण देखें →
साझा करें

|परीक्षण| |AppVeyor| |readthedocs| |coveralls| |संस्करण|

|pyversions| |लाइसेंस|

लेखक: Pahaz_

रेपो: https://github.com/pahaz/sshtunnel/

https://github.com/jmagnusson/bgtunnel से प्रेरित, जो Windows पर काम नहीं करता।

यह भी देखें: https://github.com/paramiko/paramiko/blob/master/demos/forward.py

आवश्यकताएँ

  • paramiko_

स्थापना

sshtunnel_ PyPI पर उपलब्ध है, इसलिए बस चलाएँ:

::

pip install sshtunnel

या ::

easy_install sshtunnel

या ::

conda install -c conda-forge sshtunnel

ताकि यह आपके वातावरण में स्थापित हो जाए।

स्रोत से स्थापित करने के लिए, रेपो <https://github.com/pahaz/sshtunnel>_ को क्लोन करें और चलाएँ::

python setup.py install

पैकेज का परीक्षण

परीक्षण चलाने के लिए आपको पहले tox <https://testrun.org/tox/latest/>_ की आवश्यकता होगी और चलाएँ::

python setup.py test

उपयोग परिदृश्य

एक विशिष्ट परिदृश्य जहाँ sshtunnel सहायक होता है, नीचे दिए गए चित्र में दर्शाया गया है। उपयोगकर्ता को किसी दूरस्थ सर्वर के पोर्ट (जैसे 8080) से कनेक्ट करने की आवश्यकता हो सकती है जहाँ केवल SSH पोर्ट (आमतौर पर पोर्ट 22) ही पहुँच योग्य हो। ::

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

                            |
-------------+              |    +----------+
    LOCAL    |              |    |  REMOTE  | :22 SSH
    CLIENT   | <== SSH ========> |  SERVER  | :8080 web service
-------------+              |    +----------+
                            |
                         FIREWALL (only port 22 is open)

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

चित्र1: SSH टनल के माध्यम से फ़ायरवॉल द्वारा अवरुद्ध सेवा से कैसे कनेक्ट करें।

यदि SSH सर्वर द्वारा अनुमति दी गई हो, तो एक निजी सर्वर (REMOTE SERVER के दृष्टिकोण से) तक पहुँचना भी संभव है जो बाहर से सीधे दिखाई नहीं देता (LOCAL CLIENT के दृष्टिकोण से)। ::

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

                            |
-------------+              |    +----------+               +---------
    LOCAL    |              |    |  REMOTE  |               | PRIVATE
    CLIENT   | <== SSH ========> |  SERVER  | <== local ==> | SERVER
-------------+              |    +----------+               +---------
                            |
                         FIREWALL (only port 443 is open)

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

चित्र2: SSH टनल के माध्यम से PRIVATE SERVER से कैसे कनेक्ट करें।

उपयोग के उदाहरण

API या तो टनल को आरंभ करके उसे शुरू करने की अनुमति देता है या with कॉन्टेक्स्ट का उपयोग करने की, जो टनल को शुरू और बंद करने का ध्यान रखेगा:

उदाहरण 1

ऊपर दिए गए चित्र1 के अनुरूप कोड निम्नलिखित है, जहाँ दूरस्थ सर्वर का पता pahaz.urfuclub.ru है, पासवर्ड प्रमाणीकरण है और स्थानीय बाइंड पोर्ट यादृच्छिक रूप से निर्धारित किया गया है।

.. code-block:: python

from sshtunnel import SSHTunnelForwarder

server = SSHTunnelForwarder(
    'alfa.8iq.dev',
    ssh_username="pahaz",
    ssh_password="secret",
    remote_bind_address=('127.0.0.1', 8080)
)

server.start()

print(server.local_bind_port)  # show assigned local port
# work with `SECRET SERVICE` through `server.local_bind_port`.

server.stop()

उदाहरण 2

सीधे पहुँच में न आने वाले निजी सर्वर के लिए पोर्ट फ़ॉरवर्डिंग का उदाहरण, जहाँ पासवर्ड-संरक्षित pkey प्रमाणीकरण माना गया है, दूरस्थ सर्वर की SSH सेवा पोर्ट 443 पर सुन रही है और वह पोर्ट फ़ायरवॉल में खुला है (चित्र2):

.. code-block:: python

import paramiko
import sshtunnel

with sshtunnel.open_tunnel(
    (REMOTE_SERVER_IP, 443),
    ssh_username="",
    ssh_pkey="/var/ssh/rsa_key",
    ssh_private_key_password="secret",
    remote_bind_address=(PRIVATE_SERVER_IP, 22),
    local_bind_address=('0.0.0.0', 10022)
) as tunnel:
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect('127.0.0.1', 10022)
    # do some operations with client session
    client.close()

print('FINISH!')

उदाहरण 3

Vagrant MySQL स्थानीय पोर्ट के लिए पोर्ट फ़ॉरवर्डिंग का उदाहरण:

.. code-block:: python

from sshtunnel import open_tunnel
from time import sleep

with open_tunnel(
    ('localhost', 2222),
    ssh_username="vagrant",
    ssh_password="vagrant",
    remote_bind_address=('127.0.0.1', 3306)
) as server:

    print(server.local_bind_port)
    while True:
        # press Ctrl-C for stopping
        sleep(1)

print('FINISH!')

या बस CLI का उपयोग करके:

.. code-block:: console

(bash)$ python -m sshtunnel -U vagrant -P vagrant -L :3306 -R 127.0.0.1:3306 -p 2222 localhost

उदाहरण 4

दो टनलों के ऊपर से कूदते हुए एक SSH सत्र खोलना। SSH ट्रांसपोर्ट और टनल डेमनाइज़्ड होंगे, जो बंद होने के समय कनेक्शनों के रुकने की प्रतीक्षा नहीं करेंगे।

.. code-block:: python

import sshtunnel
from paramiko import SSHClient


with sshtunnel.open_tunnel(
    ssh_address_or_host=('GW1_ip', 20022),
    remote_bind_address=('GW2_ip', 22),
) as tunnel1:
    print('Connection to tunnel1 (GW1_ip:GW1_port) OK...')
    with sshtunnel.open_tunnel(
        ssh_address_or_host=('localhost', tunnel1.local_bind_port),
        remote_bind_address=('target_ip', 22),
        ssh_username='GW2_user',
        ssh_password='GW2_pwd',
    ) as tunnel2:
        print('Connection to tunnel2 (GW2_ip:GW2_port) OK...')
        with SSHClient() as ssh:
            ssh.connect('localhost',
                port=tunnel2.local_bind_port,
                username='target_user',
                password='target_pwd',
            )
            ssh.exec_command(...)

CLI उपयोग

::

$ sshtunnel --help
usage: sshtunnel [-h] [-U SSH_USERNAME] [-p SSH_PORT] [-P SSH_PASSWORD] -R
                 IP:PORT [IP:PORT ...] [-L [IP:PORT ...]] [-k SSH_HOST_KEY]
                 [-K KEY_FILE] [-S KEY_PASSWORD] [-t] [-v] [-V] [-x IP:PORT]
                 [-c SSH_CONFIG_FILE] [-z] [-n] [-d [FOLDER ...]]
                 ssh_address

Pure python ssh tunnel utils
Version 0.5.1

positional arguments:
  ssh_address           SSH server IP address (GW for SSH tunnels)
                        set with "-- ssh_address" if immediately after -R or -L
टूल डाउनलोड करें