Skip to main content

Jump

Intro

Utility that builds a 2-level menu based on applications and their available environments. The setup that we have is that this utility resides on a 'jump' server and every time a user connects to that server (via SSH), the menu script is executed.

In our current setup, there is 2 kinds of servers: one type which has serverpilot installed and another one which is a vanilla ubuntu installation (both explained below)

This script also handles some applications/servers not being in the jumpgate.

The menu is built based on a JSON response from a server. The response looks like this:

{
    "items": [
        {
            "id": "b84b07c8-738e-4088-969f-0ee4c822fd3a",
            "in_jumpgate": false,
            "name": "test-app",
            "servers": [
                {
                    "display_name": "Staging",
                    "id": "939bf2ce-d0e0-42b8-8600-f7f7ef5db72b",
                    "ip": "1.2.3.4",
                    "is_serverpilot": true,
                    "name": "staging",
                    "port": 222,
                    "user": "serverpilot"
                },
                {
                    "display_name": "Production",
                    "id": "6a7f9169-5fe3-49d2-8eea-bfafcc53f4de",
                    "ip": "1.2.3.4",
                    "is_serverpilot": false,
                    "name": "prod",
                    "port": 222,
                    "user": "root"
                }
            ]
        }, {
            "id": "81a1afa3-f610-4b64-935f-7e93c025209b",
            "in_jumpgate": true,
            "last_backup": 1538352010,
            "name": "another-test-app",
            "servers": [
                {
                    "created_at": 1533644177,
                    "display_name": "Staging",
                    "id": "939bf2ce-d0e0-42b8-8600-f7f7ef5db72b",
                    "ip": "1.2.3.4",
                    "is_serverpilot": true,
                    "name": "staging",
                    "port": 222,
                    "updated_at": 1533808205,
                    "user": "serverpilot"
                }, {
                     "created_at": 1533644177,
                     "display_name": "Acceptance",
                     "id": "939bf2ce-d0e0-42b8-8600-f7f7ef5db72b",
                     "ip": "1.2.3.4",
                     "is_serverpilot": true,
                     "name": "acceptance",
                     "port": 222,
                     "updated_at": 1533808205,
                     "user": "serverpilot"
                 }
            ]
        }
    ]
}

This creates a menu like so:

Note that only the 2nd item is shown because the first one has the property in_jumpgate set to False. When you select an app, you get a list of its available servers (environments):

After selecting an item the SSH connection will be forwarded to that server.

Installation

Before you install the jumpgate, you need to have the dialog package installed. You can install it either via brew if you're on MacOS or apt or yum or whatever.

You can install the jumpgate via pip:

pip install pyjump

By default, the jumpgate will look for a file called .jump.env in your home directory containing the following values:

  • AUTH_KEY: If you use any kind of authentication when retrieving the items. If not, leave it empty.
  • AUTH_HEADER: If you use authentication (via a header) set this to the value of your header.
  • ENDPOINT: API endpoint from where to fetch the list of applications.

If you want to specify a different location for that file you can using the --env-file flag. Like so:

jump --env-file=/other/location/.env

Usage

As mentioned above, there's 2 ways to use this. One is locally on your machine and another one is in one central server. The latter is perfect for a team since every user just needs to ssh to the central server and everyone will see the same applications and servers (for now it does not have permission-checking built in).

Locally

If you'd like to run the script locally (assuming you've run the install script above), you just need to use jump.

On a central server

After installing the script, there's a couple things that you'd need to do.

  • In /etc/skel create an .ssh folder and generate a privatey (and public) key with ssh-keygen -t rsa. What this will do is have each created user have the same key when connecting to a remote server.
  • Copy the generated key to any authorized_keys file on any server(s) you want reachable from the script.
  • Add the following inside the .bash_profile file: jump && exit. This will execute on every user login and when the user decides to exit, it will also exit the session on the jump server.

Then you can create any user and have them use the jumpgate.

As an extra security step, add a user's own key (aka from their own laptop or pc or what have you) to the authorized_keys file for their user on the jumpgate.

Todo:

  • figure way to handle .env file after installation
  • add to pypi for easy install

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjump-1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyjump-1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pyjump-1.1.tar.gz.

File metadata

  • Download URL: pyjump-1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for pyjump-1.1.tar.gz
Algorithm Hash digest
SHA256 1e6e033a43273e729db936224c13f9bac4b5ee5addeb905b0e74db655805aff2
MD5 a01335df1bc5c585cf4daf370abd05b3
BLAKE2b-256 4528c21122cfa2f7d44b9bce14374be27fe71b8ea43d52b0148644bf0647d274

See more details on using hashes here.

File details

Details for the file pyjump-1.1-py3-none-any.whl.

File metadata

  • Download URL: pyjump-1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for pyjump-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 279320f7a9ee4240ad93afc04b0b945c164aa242880df05d18f93bb02430ff68
MD5 57fc4dd5e29e142d1e3b76ceaf21c31e
BLAKE2b-256 6078f683709b54d8544bae609d700984b0cf520d33a0315ffcc2227f755ff42e

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3

1 file

1.2

2 files

This release

1.1 This release

2 files

1.0

2 files

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