ssh2awsec2


Namessh2awsec2 JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/MacHu-GWU/ssh2awsec2-project
Summarya interactive Python CLI tool to help you SSH to your EC2 instances smoothly.
upload_time2024-06-20 03:57:40
maintainerSanhe Hu
docs_urlNone
authorSanhe Hu
requires_python>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements boto3 fire inquirer simple_aws_ec2 diskcache
Travis-CI No Travis.
coveralls test coverage
            
.. .. image:: https://readthedocs.org/projects/ssh2awsec2/badge/?version=latest
    :target: https://ssh2awsec2.readthedocs.io/en/latest/
    :alt: Documentation Status

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

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

.. image:: https://img.shields.io/pypi/v/ssh2awsec2.svg
    :target: https://pypi.python.org/pypi/ssh2awsec2

.. image:: https://img.shields.io/pypi/l/ssh2awsec2.svg
    :target: https://pypi.python.org/pypi/ssh2awsec2

.. image:: https://img.shields.io/pypi/pyversions/ssh2awsec2.svg
    :target: https://pypi.python.org/pypi/ssh2awsec2

.. image:: https://img.shields.io/badge/Release_History!--None.svg?style=social
    :target: https://github.com/MacHu-GWU/ssh2awsec2-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/ssh2awsec2-project

------

.. .. image:: https://img.shields.io/badge/Link-Document-blue.svg
    :target: https://ssh2awsec2.readthedocs.io/en/latest/

.. .. image:: https://img.shields.io/badge/Link-API-blue.svg
    :target: https://ssh2awsec2.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/ssh2awsec2-project

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

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

.. image:: https://img.shields.io/badge/Link-Download-blue.svg
    :target: https://pypi.org/pypi/ssh2awsec2#files


Welcome to ``ssh2awsec2`` Documentation
==============================================================================
``ssh2awsec2`` is a interactive Python CLI tool to help you SSH to your EC2 instances smoothly.

.. code-block:: bash

    +----- ⏱ 🟢 Start 'SSH to EC2 instance' ----------------------------------------+
    |
    | Which EC2 you want to SSH to?
    | ⬆ ⬇ Move your cursor up and down and press Enter to select.
    [?] Current selection: id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111
     > id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111
       id = i-0123456789bbbbbbb, name = 'dev-box', public ip = 222.222.222.222
       id = i-0123456789ccccccc, name = 'web-app', public ip = 333.333.333.333

    | ✅ selected: id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111
    | try to locate pem file ...
    | ✅ found pem file at: /Users/myname/ec2-pem/111122223333/us-east-1/dev.pem
    | Try to find OS username based on the AMI id = ami-0123456789abcdefg, name = ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server
    | cannot automatically detect OS username
    | Choose OS username of your EC2, if you don't know, see this document: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-get-info-about-instance
    | ⬆ ⬇ Move your cursor up and down and press Enter to select.
    [?] Current selection: ubuntu
       ec2-user
     > ubuntu
       fedora
       centos
       admin
       bitnami
       root

    | Run ssh command: ssh -i /Users/myname/ec2-pem/111122223333/us-east-1/dev.pem ubuntu@111.111.111.111
    | Precess Ctrl + D to exit SSH session
    Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1031-aws x86_64)

     * Documentation:  https://help.ubuntu.com
     * Management:     https://landscape.canonical.com
     * Support:        https://ubuntu.com/advantage

      System information as of Wed Jun 14 23:28:41 UTC 2023

      System load:  0.0                Processes:             104
      Usage of /:   52.0% of 19.20GB   Users logged in:       0
      Memory usage: 7%                 IPv4 address for ens5: 10.1.1.1
      Swap usage:   0%

     * Ubuntu Pro delivers the most comprehensive open source security and
       compliance features.

       https://ubuntu.com/aws/pro

     * Introducing Expanded Security Maintenance for Applications.
       Receive updates to over 25,000 software packages with your
       Ubuntu Pro subscription. Free for personal use.

         https://ubuntu.com/aws/pro

    Expanded Security Maintenance for Applications is not enabled.

    19 updates can be applied immediately.
    To see these additional updates run: apt list --upgradable

    Enable ESM Apps to receive additional future security updates.
    See https://ubuntu.com/esm or run: sudo pro status


    The list of available updates is more than a week old.
    To check for new updates run: sudo apt update
    New release '22.04.2 LTS' available.
    Run 'do-release-upgrade' to upgrade to it.


    2 updates could not be installed automatically. For more details,
    see /var/log/unattended-upgrades/unattended-upgrades.log

    Last login: Wed Jun 14 23:23:58 2023 from 100.100.100.100
    ubuntu@ip-10-1-1-1:~$ logout
    Connection to 111.111.111.111 closed.
    |
    +----- ⏰ 🟢 End 'SSH to EC2 instance', elapsed = 16.35 sec ---------------------+

**Usage Example**

.. code-block:: bash

    # show CLI help info
    ssh2awsec2

    # or use the short name
    sshec2

For first usage, you need to configure ``ssh2awsec2`` to locate your `AWS CLI credential <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html>`_.

.. code-block:: bash

    # show config related information
    sshec2 info

    # show config subcommand help info
    sshec2 config

    # show current config
    sshec2 config show

    # set the AWS profile
    sshec2 config set-profile --profile <your_aws_profile>

    # set to use the default AWS profile
    sshec2 config set-profile --profile default

    # set cache expire time
    sshec2 config set-cache-expire 3600

    # clear cache
    sshec2 clear-cache

Then you can use ``sshec2 ssh`` command to ssh to your AWS EC2 instance. Just follow the interactive prompt:

.. code-block:: bash

    # show help info
    sshec2 ssh --help

    # pick an EC2 and ssh into it
    sshec2 ssh

    # you can use -n to filter EC2 by name tag
    sshec2 ssh -n <name_tag_here>
    # example
    sshec2 ssh -n jump_host

    # you can use -i to filter EC2 by instance id
    sshec2 ssh -i <full_instance_id_or_chunk_here>
    # example
    sshec2 ssh -i 1a2b

    # you can use -k to filter EC2 by instance id (quote the query string)
    sshec2 ssh -k "<name_tag_key_value_pair_here>"
    # example
    sshec2 ssh -k "env=prod,owner=alice"

It prompt you to select EC2 instance and probably ask for the OS username. The selection will be cached for 24 hours, so you will see it on top of the list next time.


.. _install:

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

``ssh2awsec2`` is released on PyPI, so all you need is:

.. code-block:: console

    $ pip install ssh2awsec2

To upgrade to latest version:

.. code-block:: console

    $ pip install --upgrade ssh2awsec2

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MacHu-GWU/ssh2awsec2-project",
    "name": "ssh2awsec2",
    "maintainer": "Sanhe Hu",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "husanhe@gmail.com",
    "keywords": null,
    "author": "Sanhe Hu",
    "author_email": "husanhe@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3e/3e/092d26bfdede71c2c110d1075d53d28085ae5d87468cc5b0a7313489325f/ssh2awsec2-0.1.2.tar.gz",
    "platform": "Windows",
    "description": "\n.. .. image:: https://readthedocs.org/projects/ssh2awsec2/badge/?version=latest\n    :target: https://ssh2awsec2.readthedocs.io/en/latest/\n    :alt: Documentation Status\n\n.. image:: https://github.com/MacHu-GWU/ssh2awsec2-project/workflows/CI/badge.svg\n    :target: https://github.com/MacHu-GWU/ssh2awsec2-project/actions?query=workflow:CI\n\n.. .. image:: https://codecov.io/gh/MacHu-GWU/ssh2awsec2-project/branch/main/graph/badge.svg\n    :target: https://codecov.io/gh/MacHu-GWU/ssh2awsec2-project\n\n.. image:: https://img.shields.io/pypi/v/ssh2awsec2.svg\n    :target: https://pypi.python.org/pypi/ssh2awsec2\n\n.. image:: https://img.shields.io/pypi/l/ssh2awsec2.svg\n    :target: https://pypi.python.org/pypi/ssh2awsec2\n\n.. image:: https://img.shields.io/pypi/pyversions/ssh2awsec2.svg\n    :target: https://pypi.python.org/pypi/ssh2awsec2\n\n.. image:: https://img.shields.io/badge/Release_History!--None.svg?style=social\n    :target: https://github.com/MacHu-GWU/ssh2awsec2-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/ssh2awsec2-project\n\n------\n\n.. .. image:: https://img.shields.io/badge/Link-Document-blue.svg\n    :target: https://ssh2awsec2.readthedocs.io/en/latest/\n\n.. .. image:: https://img.shields.io/badge/Link-API-blue.svg\n    :target: https://ssh2awsec2.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/ssh2awsec2-project\n\n.. image:: https://img.shields.io/badge/Link-Submit_Issue-blue.svg\n    :target: https://github.com/MacHu-GWU/ssh2awsec2-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Request_Feature-blue.svg\n    :target: https://github.com/MacHu-GWU/ssh2awsec2-project/issues\n\n.. image:: https://img.shields.io/badge/Link-Download-blue.svg\n    :target: https://pypi.org/pypi/ssh2awsec2#files\n\n\nWelcome to ``ssh2awsec2`` Documentation\n==============================================================================\n``ssh2awsec2`` is a interactive Python CLI tool to help you SSH to your EC2 instances smoothly.\n\n.. code-block:: bash\n\n    +----- \u23f1 \ud83d\udfe2 Start 'SSH to EC2 instance' ----------------------------------------+\n    |\n    | Which EC2 you want to SSH to?\n    | \u2b06 \u2b07 Move your cursor up and down and press Enter to select.\n    [?] Current selection: id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111\n     > id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111\n       id = i-0123456789bbbbbbb, name = 'dev-box', public ip = 222.222.222.222\n       id = i-0123456789ccccccc, name = 'web-app', public ip = 333.333.333.333\n\n    | \u2705 selected: id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111\n    | try to locate pem file ...\n    | \u2705 found pem file at: /Users/myname/ec2-pem/111122223333/us-east-1/dev.pem\n    | Try to find OS username based on the AMI id = ami-0123456789abcdefg, name = ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server\n    | cannot automatically detect OS username\n    | Choose OS username of your EC2, if you don't know, see this document: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-get-info-about-instance\n    | \u2b06 \u2b07 Move your cursor up and down and press Enter to select.\n    [?] Current selection: ubuntu\n       ec2-user\n     > ubuntu\n       fedora\n       centos\n       admin\n       bitnami\n       root\n\n    | Run ssh command: ssh -i /Users/myname/ec2-pem/111122223333/us-east-1/dev.pem ubuntu@111.111.111.111\n    | Precess Ctrl + D to exit SSH session\n    Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1031-aws x86_64)\n\n     * Documentation:  https://help.ubuntu.com\n     * Management:     https://landscape.canonical.com\n     * Support:        https://ubuntu.com/advantage\n\n      System information as of Wed Jun 14 23:28:41 UTC 2023\n\n      System load:  0.0                Processes:             104\n      Usage of /:   52.0% of 19.20GB   Users logged in:       0\n      Memory usage: 7%                 IPv4 address for ens5: 10.1.1.1\n      Swap usage:   0%\n\n     * Ubuntu Pro delivers the most comprehensive open source security and\n       compliance features.\n\n       https://ubuntu.com/aws/pro\n\n     * Introducing Expanded Security Maintenance for Applications.\n       Receive updates to over 25,000 software packages with your\n       Ubuntu Pro subscription. Free for personal use.\n\n         https://ubuntu.com/aws/pro\n\n    Expanded Security Maintenance for Applications is not enabled.\n\n    19 updates can be applied immediately.\n    To see these additional updates run: apt list --upgradable\n\n    Enable ESM Apps to receive additional future security updates.\n    See https://ubuntu.com/esm or run: sudo pro status\n\n\n    The list of available updates is more than a week old.\n    To check for new updates run: sudo apt update\n    New release '22.04.2 LTS' available.\n    Run 'do-release-upgrade' to upgrade to it.\n\n\n    2 updates could not be installed automatically. For more details,\n    see /var/log/unattended-upgrades/unattended-upgrades.log\n\n    Last login: Wed Jun 14 23:23:58 2023 from 100.100.100.100\n    ubuntu@ip-10-1-1-1:~$ logout\n    Connection to 111.111.111.111 closed.\n    |\n    +----- \u23f0 \ud83d\udfe2 End 'SSH to EC2 instance', elapsed = 16.35 sec ---------------------+\n\n**Usage Example**\n\n.. code-block:: bash\n\n    # show CLI help info\n    ssh2awsec2\n\n    # or use the short name\n    sshec2\n\nFor first usage, you need to configure ``ssh2awsec2`` to locate your `AWS CLI credential <https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html>`_.\n\n.. code-block:: bash\n\n    # show config related information\n    sshec2 info\n\n    # show config subcommand help info\n    sshec2 config\n\n    # show current config\n    sshec2 config show\n\n    # set the AWS profile\n    sshec2 config set-profile --profile <your_aws_profile>\n\n    # set to use the default AWS profile\n    sshec2 config set-profile --profile default\n\n    # set cache expire time\n    sshec2 config set-cache-expire 3600\n\n    # clear cache\n    sshec2 clear-cache\n\nThen you can use ``sshec2 ssh`` command to ssh to your AWS EC2 instance. Just follow the interactive prompt:\n\n.. code-block:: bash\n\n    # show help info\n    sshec2 ssh --help\n\n    # pick an EC2 and ssh into it\n    sshec2 ssh\n\n    # you can use -n to filter EC2 by name tag\n    sshec2 ssh -n <name_tag_here>\n    # example\n    sshec2 ssh -n jump_host\n\n    # you can use -i to filter EC2 by instance id\n    sshec2 ssh -i <full_instance_id_or_chunk_here>\n    # example\n    sshec2 ssh -i 1a2b\n\n    # you can use -k to filter EC2 by instance id (quote the query string)\n    sshec2 ssh -k \"<name_tag_key_value_pair_here>\"\n    # example\n    sshec2 ssh -k \"env=prod,owner=alice\"\n\nIt prompt you to select EC2 instance and probably ask for the OS username. The selection will be cached for 24 hours, so you will see it on top of the list next time.\n\n\n.. _install:\n\nInstall\n------------------------------------------------------------------------------\n\n``ssh2awsec2`` is released on PyPI, so all you need is:\n\n.. code-block:: console\n\n    $ pip install ssh2awsec2\n\nTo upgrade to latest version:\n\n.. code-block:: console\n\n    $ pip install --upgrade ssh2awsec2\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "a interactive Python CLI tool to help you SSH to your EC2 instances smoothly.",
    "version": "0.1.2",
    "project_urls": {
        "Download": "https://pypi.python.org/pypi/ssh2awsec2/0.1.2#downloads",
        "Homepage": "https://github.com/MacHu-GWU/ssh2awsec2-project"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6badb28c3fbd84e33da52dacd5691bdc60eb028e89b705f875c18f426750767d",
                "md5": "cd1668f39504347f10c328854137a80f",
                "sha256": "531395ef9bd74176155d97898d3eff5eddded2d1721bc0025a631aeb81845ef6"
            },
            "downloads": -1,
            "filename": "ssh2awsec2-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cd1668f39504347f10c328854137a80f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 23994,
            "upload_time": "2024-06-20T03:57:39",
            "upload_time_iso_8601": "2024-06-20T03:57:39.655487Z",
            "url": "https://files.pythonhosted.org/packages/6b/ad/b28c3fbd84e33da52dacd5691bdc60eb028e89b705f875c18f426750767d/ssh2awsec2-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e3e092d26bfdede71c2c110d1075d53d28085ae5d87468cc5b0a7313489325f",
                "md5": "c58e17f5e592b64fe893a9691099db64",
                "sha256": "d222cc0ecf4e2a0a1118903f048870aca65b9535409679372a8c73b903dede73"
            },
            "downloads": -1,
            "filename": "ssh2awsec2-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c58e17f5e592b64fe893a9691099db64",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 24956,
            "upload_time": "2024-06-20T03:57:40",
            "upload_time_iso_8601": "2024-06-20T03:57:40.804956Z",
            "url": "https://files.pythonhosted.org/packages/3e/3e/092d26bfdede71c2c110d1075d53d28085ae5d87468cc5b0a7313489325f/ssh2awsec2-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-20 03:57:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MacHu-GWU",
    "github_project": "ssh2awsec2-project",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "boto3",
            "specs": []
        },
        {
            "name": "fire",
            "specs": [
                [
                    ">=",
                    "0.4.0"
                ],
                [
                    "<",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "inquirer",
            "specs": [
                [
                    "<",
                    "4.0.0"
                ],
                [
                    ">=",
                    "3.1.3"
                ]
            ]
        },
        {
            "name": "simple_aws_ec2",
            "specs": [
                [
                    ">=",
                    "0.9.1"
                ],
                [
                    "<",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "diskcache",
            "specs": [
                [
                    ">=",
                    "5.0.3"
                ],
                [
                    "<",
                    "6.0.0"
                ]
            ]
        }
    ],
    "lcname": "ssh2awsec2"
}
        
Elapsed time: 1.17949s