Code Monkey home page Code Monkey logo

iam-ssh's Introduction

iam-ssh

Originally forked from Fullscreen/iam-authorized-keys-command thanks to work by @stefansundin. This command is a simple wrapper around AWS IAM SSH key storage that, if given an IAM user as an argument will return the SSH public key for that user. Using this, we can call this command from SSH to verify the the user has permission to SSH onto a node. The only cavaet is that the AWS username must be the same as the username on the host. This binary is distributed to the hosts and called from the sshd_config as shown below. This also means each host must have permissions to read SSH public keys from AWS. A sample permission policy is given below.

Example sshd_config

AuthorizedKeysFile none
AuthorizedKeysCommand /path/to/compiled/binary
AuthorizedKeysCommandUser nobody

If you still want to be able to use the authorized_keys file for some users, e.g. in case IAM is experiencing downtime, you can add something like the following:

Match User ubuntu
  AuthorizedKeysFile %h/.ssh/authorized_keys

Don't forget to restart the ssh service:

service ssh restart

IAM Role Permissions

This script needs the following policy to execute properly, so make sure you apply it to your EC2 Role:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "iam:ListSSHPublicKeys",
                "iam:GetSSHPublicKey"
            ],
            "Resource": "*"
        }
    ]
}

Deployment

Though this is a simple tool, distribution is still a thing. We use the gox utility to build for multiple architectures. To build, first install this utility and then run ./build.sh. This will create the architecture-specific binaries in the corresponding directories under dist.

iam-ssh's People

Contributors

onetwopunch avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.