acore-db-ssh-tunnel


Nameacore-db-ssh-tunnel JSON
Version 0.1.4 PyPI version JSON
download
home_pagehttps://github.com/MacHu-GWU/acore_db_ssh_tunnel-project
SummaryCreate Database SSH Tunnel for Azerothcore World of Warcraft MySQL Database
upload_time2024-06-20 15:11:28
maintainerSanhe Hu
docs_urlNone
authorSanhe Hu
requires_python>=3.7
licenseMIT
keywords
VCS
bugtrack_url
requirements SQLAlchemy PyMySQL
Travis-CI No Travis.
coveralls test coverage
            
.. .. image:: https://readthedocs.org/projects/acore-db-ssh-tunnel/badge/?version=latest
    :target: https://acore-db-ssh-tunnel.readthedocs.io/en/latest/
    :alt: Documentation Status

.. image:: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/actions/workflows/main.yml/badge.svg
    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/actions?query=workflow:CI

.. .. image:: https://codecov.io/gh/MacHu-GWU/acore_db_ssh_tunnel-project/branch/main/graph/badge.svg
    :target: https://codecov.io/gh/MacHu-GWU/acore_db_ssh_tunnel-project

.. image:: https://img.shields.io/pypi/v/acore-db-ssh-tunnel.svg
    :target: https://pypi.python.org/pypi/acore-db-ssh-tunnel

.. image:: https://img.shields.io/pypi/l/acore-db-ssh-tunnel.svg
    :target: https://pypi.python.org/pypi/acore-db-ssh-tunnel

.. image:: https://img.shields.io/pypi/pyversions/acore-db-ssh-tunnel.svg
    :target: https://pypi.python.org/pypi/acore-db-ssh-tunnel

.. image:: https://img.shields.io/badge/Release_History!--None.svg?style=social
    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/blob/main/release-history.rst

.. image:: https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social
    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project

------

.. .. image:: https://img.shields.io/badge/Link-Document-blue.svg
    :target: https://acore-db-ssh-tunnel.readthedocs.io/en/latest/

.. .. image:: https://img.shields.io/badge/Link-API-blue.svg
    :target: https://acore-db-ssh-tunnel.readthedocs.io/en/latest/py-modindex.html

.. image:: https://img.shields.io/badge/Link-Install-blue.svg
    :target: `install`_

.. image:: https://img.shields.io/badge/Link-GitHub-blue.svg
    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project

.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg
    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/issues

.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg
    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/issues

.. image:: https://img.shields.io/badge/Link-Download-blue.svg
    :target: https://pypi.org/pypi/acore-db-ssh-tunnel#files


Welcome to ``acore_db_ssh_tunnel`` Documentation
==============================================================================
出于安全考虑, 通常数据库都会被部署到私网中, 是不允许直接从公网访问的. 为了能让开发者从工具配置齐全的开发电脑连接到数据库, 通常采用跳板机 + `SSH Tunnel <https://www.ssh.com/academy/ssh/tunneling>`_ 技术实现. 具体方法是用 SSH 和 EC2 的秘钥在本地机器上建立一个 tunnel, 所有本来要发送到 Database domain 的流量都发送到 127.0.0.1, 然后 SSH 会自动将流量发送到跳板机, 然后堡垒机再发送到 Database.

本项目将创建, 关闭, 查看, 以及测试 SSH Tunnel 的方法封装成了一个 Python package, 以便于在 Python 代码中使用.

**用例**

.. code-block:: python

    from acore_db_ssh_tunnel import api

    def create_ssh_tunnel():
        api.create_ssh_tunnel(
            path_pem_file=path_pem_file,
            db_host=db_host,
            db_port=db_port,
            jump_host_username=jump_host_username,
            jump_host_public_ip=jump_host_public_ip,
        )


    def list_ssh_tunnel():
        api.list_ssh_tunnel(path_pem_file)


    def test_ssh_tunnel():
        api.test_ssh_tunnel(
            db_port=db_port,
            db_username=db_username,
            db_password=db_password,
            db_name=db_name,
        )


    def kill_ssh_tunnel():
        api.kill_ssh_tunnel(path_pem_file)


    # edit the following variables to your own
    db_host = "my-server.1a2b3c4d5e6f.us-east-1.rds.amazonaws.com"
    db_port = 3306
    db_username = "admin"
    db_password = "admin"
    db_name = "my_database"
    jump_host_username = "ubuntu"
    jump_host_public_ip = "111.111.111.111"
    path_pem_file = "/Users/myusername/ec2-key.pem"

    # create_ssh_tunnel() # run this first
    # list_ssh_tunnel() # then this
    # test_ssh_tunnel() # then this
    # kill_ssh_tunnel() # then clean up


.. _install:

Install
------------------------------------------------------------------------------

``acore_db_ssh_tunnel`` is released on PyPI, so all you need is to:

.. code-block:: console

    $ pip install acore-db-ssh-tunnel

To upgrade to latest version:

.. code-block:: console

    $ pip install --upgrade acore-db-ssh-tunnel

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project",
    "name": "acore-db-ssh-tunnel",
    "maintainer": "Sanhe Hu",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "husanhe@gmail.com",
    "keywords": null,
    "author": "Sanhe Hu",
    "author_email": "husanhe@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2f/82/ac49332f8efd3605502db593486ece0defffe11aba302f7ad34a38bb831d/acore_db_ssh_tunnel-0.1.4.tar.gz",
    "platform": "Windows",
    "description": "\n.. .. image:: https://readthedocs.org/projects/acore-db-ssh-tunnel/badge/?version=latest\n    :target: https://acore-db-ssh-tunnel.readthedocs.io/en/latest/\n    :alt: Documentation Status\n\n.. image:: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/actions/workflows/main.yml/badge.svg\n    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/actions?query=workflow:CI\n\n.. .. image:: https://codecov.io/gh/MacHu-GWU/acore_db_ssh_tunnel-project/branch/main/graph/badge.svg\n    :target: https://codecov.io/gh/MacHu-GWU/acore_db_ssh_tunnel-project\n\n.. image:: https://img.shields.io/pypi/v/acore-db-ssh-tunnel.svg\n    :target: https://pypi.python.org/pypi/acore-db-ssh-tunnel\n\n.. image:: https://img.shields.io/pypi/l/acore-db-ssh-tunnel.svg\n    :target: https://pypi.python.org/pypi/acore-db-ssh-tunnel\n\n.. image:: https://img.shields.io/pypi/pyversions/acore-db-ssh-tunnel.svg\n    :target: https://pypi.python.org/pypi/acore-db-ssh-tunnel\n\n.. image:: https://img.shields.io/badge/Release_History!--None.svg?style=social\n    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/blob/main/release-history.rst\n\n.. image:: https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social\n    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project\n\n------\n\n.. .. image:: https://img.shields.io/badge/Link-Document-blue.svg\n    :target: https://acore-db-ssh-tunnel.readthedocs.io/en/latest/\n\n.. .. image:: https://img.shields.io/badge/Link-API-blue.svg\n    :target: https://acore-db-ssh-tunnel.readthedocs.io/en/latest/py-modindex.html\n\n.. image:: https://img.shields.io/badge/Link-Install-blue.svg\n    :target: `install`_\n\n.. image:: https://img.shields.io/badge/Link-GitHub-blue.svg\n    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project\n\n.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg\n    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg\n    :target: https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Download-blue.svg\n    :target: https://pypi.org/pypi/acore-db-ssh-tunnel#files\n\n\nWelcome to ``acore_db_ssh_tunnel`` Documentation\n==============================================================================\n\u51fa\u4e8e\u5b89\u5168\u8003\u8651, \u901a\u5e38\u6570\u636e\u5e93\u90fd\u4f1a\u88ab\u90e8\u7f72\u5230\u79c1\u7f51\u4e2d, \u662f\u4e0d\u5141\u8bb8\u76f4\u63a5\u4ece\u516c\u7f51\u8bbf\u95ee\u7684. \u4e3a\u4e86\u80fd\u8ba9\u5f00\u53d1\u8005\u4ece\u5de5\u5177\u914d\u7f6e\u9f50\u5168\u7684\u5f00\u53d1\u7535\u8111\u8fde\u63a5\u5230\u6570\u636e\u5e93, \u901a\u5e38\u91c7\u7528\u8df3\u677f\u673a + `SSH Tunnel <https://www.ssh.com/academy/ssh/tunneling>`_ \u6280\u672f\u5b9e\u73b0. \u5177\u4f53\u65b9\u6cd5\u662f\u7528 SSH \u548c EC2 \u7684\u79d8\u94a5\u5728\u672c\u5730\u673a\u5668\u4e0a\u5efa\u7acb\u4e00\u4e2a tunnel, \u6240\u6709\u672c\u6765\u8981\u53d1\u9001\u5230 Database domain \u7684\u6d41\u91cf\u90fd\u53d1\u9001\u5230 127.0.0.1, \u7136\u540e SSH \u4f1a\u81ea\u52a8\u5c06\u6d41\u91cf\u53d1\u9001\u5230\u8df3\u677f\u673a, \u7136\u540e\u5821\u5792\u673a\u518d\u53d1\u9001\u5230 Database.\n\n\u672c\u9879\u76ee\u5c06\u521b\u5efa, \u5173\u95ed, \u67e5\u770b, \u4ee5\u53ca\u6d4b\u8bd5 SSH Tunnel \u7684\u65b9\u6cd5\u5c01\u88c5\u6210\u4e86\u4e00\u4e2a Python package, \u4ee5\u4fbf\u4e8e\u5728 Python \u4ee3\u7801\u4e2d\u4f7f\u7528.\n\n**\u7528\u4f8b**\n\n.. code-block:: python\n\n    from acore_db_ssh_tunnel import api\n\n    def create_ssh_tunnel():\n        api.create_ssh_tunnel(\n            path_pem_file=path_pem_file,\n            db_host=db_host,\n            db_port=db_port,\n            jump_host_username=jump_host_username,\n            jump_host_public_ip=jump_host_public_ip,\n        )\n\n\n    def list_ssh_tunnel():\n        api.list_ssh_tunnel(path_pem_file)\n\n\n    def test_ssh_tunnel():\n        api.test_ssh_tunnel(\n            db_port=db_port,\n            db_username=db_username,\n            db_password=db_password,\n            db_name=db_name,\n        )\n\n\n    def kill_ssh_tunnel():\n        api.kill_ssh_tunnel(path_pem_file)\n\n\n    # edit the following variables to your own\n    db_host = \"my-server.1a2b3c4d5e6f.us-east-1.rds.amazonaws.com\"\n    db_port = 3306\n    db_username = \"admin\"\n    db_password = \"admin\"\n    db_name = \"my_database\"\n    jump_host_username = \"ubuntu\"\n    jump_host_public_ip = \"111.111.111.111\"\n    path_pem_file = \"/Users/myusername/ec2-key.pem\"\n\n    # create_ssh_tunnel() # run this first\n    # list_ssh_tunnel() # then this\n    # test_ssh_tunnel() # then this\n    # kill_ssh_tunnel() # then clean up\n\n\n.. _install:\n\nInstall\n------------------------------------------------------------------------------\n\n``acore_db_ssh_tunnel`` is released on PyPI, so all you need is to:\n\n.. code-block:: console\n\n    $ pip install acore-db-ssh-tunnel\n\nTo upgrade to latest version:\n\n.. code-block:: console\n\n    $ pip install --upgrade acore-db-ssh-tunnel\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Create Database SSH Tunnel for Azerothcore World of Warcraft MySQL Database",
    "version": "0.1.4",
    "project_urls": {
        "Download": "https://pypi.python.org/pypi/acore_db_ssh_tunnel/0.1.4#downloads",
        "Homepage": "https://github.com/MacHu-GWU/acore_db_ssh_tunnel-project"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a91a7f3a45f0800fad701e3e7a98d7637db748449013d4b8319552981d473cf",
                "md5": "26d18100e40263cf865c9ad6d1e73d78",
                "sha256": "e1dc396ff2809b792edd2bb92bc0e35eb2b96ce75b68b84ed12e11f60324f52b"
            },
            "downloads": -1,
            "filename": "acore_db_ssh_tunnel-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26d18100e40263cf865c9ad6d1e73d78",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13468,
            "upload_time": "2024-06-20T15:11:26",
            "upload_time_iso_8601": "2024-06-20T15:11:26.612064Z",
            "url": "https://files.pythonhosted.org/packages/8a/91/a7f3a45f0800fad701e3e7a98d7637db748449013d4b8319552981d473cf/acore_db_ssh_tunnel-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f82ac49332f8efd3605502db593486ece0defffe11aba302f7ad34a38bb831d",
                "md5": "b618ab64b55ebdab56b2e9f4f332eadb",
                "sha256": "a096e6b90b24520a978d0fc75a0641a1ea6f432e939f93ecf8792c821708abf5"
            },
            "downloads": -1,
            "filename": "acore_db_ssh_tunnel-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b618ab64b55ebdab56b2e9f4f332eadb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 14856,
            "upload_time": "2024-06-20T15:11:28",
            "upload_time_iso_8601": "2024-06-20T15:11:28.708222Z",
            "url": "https://files.pythonhosted.org/packages/2f/82/ac49332f8efd3605502db593486ece0defffe11aba302f7ad34a38bb831d/acore_db_ssh_tunnel-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-20 15:11:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MacHu-GWU",
    "github_project": "acore_db_ssh_tunnel-project",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "SQLAlchemy",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ],
                [
                    "<",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "PyMySQL",
            "specs": [
                [
                    ">=",
                    "1.0.1"
                ],
                [
                    "<",
                    "2.0.0"
                ]
            ]
        }
    ],
    "lcname": "acore-db-ssh-tunnel"
}
        
Elapsed time: 1.18351s