{ "info": { "author": "Olivier Orabona", "author_email": "olivier.orabona@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Security", "Topic :: System :: Shells", "Topic :: System :: Systems Administration", "Topic :: System :: Systems Administration :: Authentication/Directory" ], "description": "# GitHub-SSH-Auth\n\n[![Build Status](https://travis-ci.com/oorabona/github-ssh-auth.svg?branch=master)](https://travis-ci.com/oorabona/github-ssh-auth)\n\n# About\n\nThis project aims to provide a way for `SSHd` to authenticate users on shell boxes using GitHub API v3 SSH keys of users in your organization.\n\n# How it works\n\n***SSH Authentication against GitHub API*** is done using a feature of `OpenSSH`, namely `AuthorizedKeysCommand` and `AuthorizedKeysCommandUser`.\n\nEverytime a user connects, the script will be called with the login as command line parameter.\n\nIn detail, the following happens :\n1. `sshd` deamon runs `github-ssh-auth` under the user defined by `AuthorizedKeysCommandUser` option.\n\n2. `github-ssh-auth` reads its configuration file (by default `/etc/github-ssh/conf`)\n\n3. according to the configuration file, it looks up the username given by `sshd` and checks if that user is granted permission to connect to this host\n\n4. if yes, it tries to read the cache file (recommended but can be disabled) to find user's keys. If no cache file found or if disabled, then it queries GitHub API to get the keys and creates the cache (if enabled).\n\n5. github-ssh-auth returns a list of eligible ssh public keys to standard output to be processed by `sshd`\n\nThe rest is handled by `sshd` itself, i.e. checking validity of that public key and the rest of the connection handling.\n\n# Updating keys and cache use\n\nTo avoid flooding GitHub API and consequently being temporarily banned from using their API in case of massive connects, it is recommended to keep the cache enabled and update the keys only few times a day. The periodicity is yours and that is why there is a special `update` command line parameter for that.\n\nConsider the following scenario:\n- cache is enabled\n- cache file already exists\n- a new user has joined the team OR an existing user replaced his/her keys\n\nIn such case, the cache file will **NOT** be updated when authentication happens, this is the behavior set by design to separate concerns and prevent connection to the outside world being in the critical path for authentication.\n\nInstead, a locally defined `cron` should either:\n- call `github-ssh-update` to update cache\n- delete cache file (by default `/etc/github-ssh/cache.json`) which will force recreation when next auth happens\n\nBoth will have the same outcome but the former is cleaner than the latter.\n\nAll in all, choice is yours :wink:\n\n# Installation\n\nSince this Python module deals with SSH authentication, it should be installed globally, hence:\n\n```\n$ sudo pip install github-ssh-auth\n```\n\nThis will install the following program and its shortcuts in `/usr/local/bin`:\n\n## github-ssh\n\nThe real application, handling all options, but for convenience the shortcuts described after can be used.\n\n### Usage\n\n```\nUsage: github-ssh [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --version Show the version and exit.\n --help Show this message and exit.\n\nCommands:\n auth Authenticate user.\n update Update GitHub SSH Auth cache file (users, teams, keys).\n```\n\n## github-ssh-auth\n\nResponsible for authentication itself, this one is to be called by `sshd` itself.\n\n### Usage\n\n```\nUsage: github-ssh-auth [OPTIONS] LOGIN\n\n Authenticate user.\n\nOptions:\n -c, --config TEXT\n --help Show this message and exit.\n```\n\n## github-ssh-update\n\nResponsible for updating cache file, it can be scheduled to run periodicaly to ensure synchronization with updated keys from Github.\n\n### Usage\n\n```\nUsage: github-ssh-update [OPTIONS]\n\n Update GitHub SSH Auth cache file (users, teams, keys).\n\nOptions:\n -c, --config TEXT\n --help Show this message and exit.\n```\n\n> Note:\nIn some distros, `/usr/local/bin` is not eligible for `sshd` daemon because of some obscure group permissions reason. Moving the binaries from `/usr/local/bin` to `/usr/bin` make them work like a charm !\n\n# Configuration\n\n## SSH configuration in `/etc/ssh/sshd_config`\n\nThese lines should be somewhere in your `sshd` configuration file. Usually in `/etc/ssh/sshd_config` :\n\n```\nAuthorizedKeysCommand /usr/bin/github-ssh-auth %u\nAuthorizedKeysCommandUser nobody\n```\n\n## GitHub token requirements\n\nSince this application is dealing with some sensitive data (users and their team memberships) within an organization, we will need to create a so-called `Personal access tokens`.\n\nTo do that, fire up your GitHub organization dashboard, look for `Settings` then `Developer settings`.\n\nThen click on `Generate new token` and set its permissions to:\n> read:org\n\nThis is the only requirement so that the API can be queried for users and teams memberships. All users keys are public by default an can be accessed from the outside world without authentication against GitHub API.\n\nSee for yourself, go to `https://github.com/.keys`. :rocket:\n\n## GitHub SSH Auth configuration file\n\nIt resides by default in `/etc/github-ssh/conf` but of course you can change it using `-c` flag when calling (see above).\n\nThe format is a standard INI style, as per `configparser`.\n\n### Configuration file template\n\nBelow is the complete grammar with inline comments:\n\n```ini\n[global]\n# Comments should start with a # and must be full lines\n# The following two lines are mandatory\naccess_token = \norganization = \n\n# In case of connectivity lost and to prevent too many connections to GitHub API,\n# it is strongly recommended to set it to an absolute filepath.\n# Default (when not present) is set to /etc/github-ssh/cache.json and equivalent to:\n# cache_file = /etc/github-ssh/cache.json\n\n# If you want to disable, set it to 'false'\n# cache_file = [/path/to/file | false]\n\n# Unless overridden after, users (whether individual or teams) will have these configurations applied.\n# By default, nothing is set so basically no one will be granted access\n# The '<' case means that if a local exists with the same name as a GitHub user,\n# it will be granted access. It is a shorthand to avoid a too\n# complex, verbose yet common use case where every developer would\n# like to have his/her own shell account.\nteams_default = [ list,of,local,users,or,< ]\nusers_default = [ list,of,local,users,or,< ]\n\n# Configuration below will override team defaults\n[teams]\n = [ list,of,local,users,or,< ]\n...\n\n# And below to override default users setup\n[users]\n = [ list,of,local,users,or,< ]\n...\n```\n\n### Special note on the '<'\n\nJust a quick focus on that special caracter, designed to allow a GitHub `user` to connect provided that:\n\n- `user` is the Github handle, being part of the organization, **and**\n- `user` exists in the local user base (i.e. it is present when you do a `getent passwd`)\n\n#### Real world example\n\nLet's say Acme Corp. wants all its developers connect with their GitHub accounts. Let's say users `jdoe` `bob` `alice` are such handles. Also these user handles are also the respective handlers in GitHub.\n\nThen with this simple configuration, we allow globally all these users to login with their handles:\n\n```ini\n[global]\n...other config skipped for brevety...\n\nusers_default = <\n```\n\nNow if you only want `bob` to connect using login `bob`, the configuration file would look like this one:\n\n```ini\n[global]\n...other config skipped for brevety...\n\nusers_default =\n\n[users]\nbob = <\n```\n\n### Other real world examples\n\nSome other ready-to-be-deployed-or-almost can be found in the `example` directory.\n\n# Testing\n\nAs this is my first Python module, and even my first Python program ever, I tried different methods to handle testing.\nHaving a lot of shortcomings with some of the tools in the ecosystem (`tox`, etc.) due to complexity and such I decided to give a go to Docker with Python installed and everything is done inside containers, which is *super fast*.\n\nSo once you have `git clone`d the repository locally, you can see it for yourself by issuing a:\n\n```\n$ make help\nclean - remove all build, test, coverage and Python artifacts\nclean-build - remove build artifacts\nclean-pyc - remove Python file artifacts\nclean-test - remove test and coverage artifacts\nlint - check style with flake8\ntest - run tests quickly with the default Python\ncoverage - check code coverage quickly with the default Python\ndocs - generate Sphinx HTML documentation, including API docs\nrelease - package and upload a release\ntest-release - package and upload a release to testpy repository\ndist - package\ninstall - install the package to the active Python's site-packages\n```\n\n# Contributions\n\nComments, issues, PR as :beer: will be warmly welcomed !\n\n# License\n\nGPLv3+\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/oorabona/github-ssh-auth", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "github-ssh-auth", "package_url": "https://pypi.org/project/github-ssh-auth/", "platform": "", "project_url": "https://pypi.org/project/github-ssh-auth/", "project_urls": { "Homepage": "https://github.com/oorabona/github-ssh-auth" }, "release_url": "https://pypi.org/project/github-ssh-auth/0.9.1/", "requires_dist": [ "click (>=7.0)", "PyGithub (>=1.2.0)", "configparser", "flake8 ; extra == 'all'", "pytest ; extra == 'all'", "pytest-cov ; extra == 'all'", "coverage ; extra == 'all'", "flake8 ; extra == 'tests'", "pytest ; extra == 'tests'", "pytest-cov ; extra == 'tests'", "coverage ; extra == 'tests'" ], "requires_python": "", "summary": "Authenticate SSH users keys with GitHub", "version": "0.9.1" }, "last_serial": 5121329, "releases": { "0.9.0": [ { "comment_text": "", "digests": { "md5": "630cbb65ab4dc5714b4e2bde315db057", "sha256": "a49830d69f39f59b0991448af7b6235f3e2fb7fd6a136d064266dd438c005019" }, "downloads": -1, "filename": "github-ssh-auth-0.9.0.tar.gz", "has_sig": false, "md5_digest": "630cbb65ab4dc5714b4e2bde315db057", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11366, "upload_time": "2019-02-10T21:12:18", "url": "https://files.pythonhosted.org/packages/de/15/10e924b32036f5942676a979d1501e46e5f5740a1f400028a34e57ce1302/github-ssh-auth-0.9.0.tar.gz" } ], "0.9.1": [ { "comment_text": "", "digests": { "md5": "a59b1a277ee8b0041e2fdb61da9bc625", "sha256": "c9f367a6ab1b7934d0ee1426f86178e51183714188dcb09c61180f8cb4e89d12" }, "downloads": -1, "filename": "github_ssh_auth-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a59b1a277ee8b0041e2fdb61da9bc625", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 24652, "upload_time": "2019-04-09T23:35:47", "url": "https://files.pythonhosted.org/packages/c3/8c/dd104e525a70cfa139281726b83e8b7fcebcd13e52447f1edeabeabe35dd/github_ssh_auth-0.9.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d66d674af858546ffc068001710b3e54", "sha256": "57269a316e168822f9dd0856d85a3242192eefb06a3087a00b1a79dd7e019516" }, "downloads": -1, "filename": "github-ssh-auth-0.9.1.tar.gz", "has_sig": false, "md5_digest": "d66d674af858546ffc068001710b3e54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14232, "upload_time": "2019-04-09T23:35:49", "url": "https://files.pythonhosted.org/packages/2e/93/dbaf6bc667bb64a4d6a2837b74a731d5093af98363cb796cd031fbccb23a/github-ssh-auth-0.9.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a59b1a277ee8b0041e2fdb61da9bc625", "sha256": "c9f367a6ab1b7934d0ee1426f86178e51183714188dcb09c61180f8cb4e89d12" }, "downloads": -1, "filename": "github_ssh_auth-0.9.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a59b1a277ee8b0041e2fdb61da9bc625", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 24652, "upload_time": "2019-04-09T23:35:47", "url": "https://files.pythonhosted.org/packages/c3/8c/dd104e525a70cfa139281726b83e8b7fcebcd13e52447f1edeabeabe35dd/github_ssh_auth-0.9.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d66d674af858546ffc068001710b3e54", "sha256": "57269a316e168822f9dd0856d85a3242192eefb06a3087a00b1a79dd7e019516" }, "downloads": -1, "filename": "github-ssh-auth-0.9.1.tar.gz", "has_sig": false, "md5_digest": "d66d674af858546ffc068001710b3e54", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14232, "upload_time": "2019-04-09T23:35:49", "url": "https://files.pythonhosted.org/packages/2e/93/dbaf6bc667bb64a4d6a2837b74a731d5093af98363cb796cd031fbccb23a/github-ssh-auth-0.9.1.tar.gz" } ] }