Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

option to limit access to an IAM group instead of all IAM users #19

Closed
wants to merge 2 commits into from

Conversation

dylansmith
Copy link

No description provided.

Copy link
Contributor

@michaelwittig michaelwittig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is the right place for this. why not checking when the user actually logs in? in the authorized_keys_command.sh ? or why not configuring this by not allowing the ec2 instance to fetch the public key only for certain users instead of * ?

install.sh Outdated
@@ -13,6 +13,11 @@ cd $tmpdir/aws-ec2-ssh
cp authorized_keys_command.sh /opt/authorized_keys_command.sh
cp import_users.sh /opt/import_users.sh

# To control which users are given access, uncomment the line below changing
# GROUPNAME to the name of the IAM group for users. If you leave it blank, all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank seems to be not correct. you check for ##ALL##

@@ -1,5 +1,18 @@
#!/bin/bash

# Specify an IAM group for users who should be given access, or leave this with
# the value '##ALL##' to give access to all IAM users.
UsersGroup="##ALL##"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not blank?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. so it needs to be changed in the install.sh accordingly

@shinenelson
Copy link
Contributor

shinenelson commented Feb 13, 2017

Aha! I was just going to open a pull request with this feature. I've implemented this in a slightly different way though. My implementation can accept multiple IAM Groups.

Check out my import-user-from-groups branch, if you're interested.

@michaelwittig
Copy link
Contributor

Hi! What do you think about putting the group membership check into the authorized_keys_command.sh script? This would eliminate the issue with group member ship changes and will also apply immediately

@shinenelson
Copy link
Contributor

I'd like importing users from groups so that I can fine-tune what kind of privileges that I can give them on the servers. I'd like to put one group in a chroot or restrict others to an lshell, etc. The import process and the useradd command is the best place to achieve that.

But yes, it is appropriate to authorized_keys_command too. I'll open a pull request in a while. 😉

@michaelwittig
Copy link
Contributor

michaelwittig commented Feb 22, 2017

I see, The two requirements are:

  • allow only a subset of users to login
  • configure local users depending in the group membership

The first one seems simpler by checking for the group membership in authorized_keys_command.
The second one seems more complicated because the user needs to configure group restrictions outside of IAM I guess.

I'm wondering if it would be possible to store the configuration in the IAM group as well.

@shinenelson
Copy link
Contributor

I just opened pull request #23 that implemented the authorization strategy from AWS IAM groups from with the authorized_keys_command.

The second one seems more complicated because the user needs to configure group restrictions outside of IAM I guess.

That part seems pretty straight-forward with my implementation in my import-user-from-groups branch. I'm using the same on my production environment as well. I have a lot of users on my account that don't need to have access to any of my EC2 Instances. What's the point of creating users for them on the instances if they're not going to be used? (that's partly a security concern as well).

@mvanbaak
Copy link
Contributor

Putting it in the authorized_keys_command makes logging in to the instance even slower than it already is. While it has it's advantage (like michaelwittig said) it has, in my opinion, a very big downside. All the API calls done in the shellscript while logging in makes it too slow. I tried and got a lot of complaints from developers that they thought the instances were acting up.

I like the way it is done in the import-user-from-groups branch better.

@michaelwittig
Copy link
Contributor

@shinenelson Is their a open PR with your import-user-from-groups branch? Maybe I'm missing something?

@michaelwittig michaelwittig mentioned this pull request Mar 28, 2017
@shinenelson
Copy link
Contributor

@shinenelson Is their a open PR with your import-user-from-groups branch? Maybe I'm missing something?

No, I just mentioned it in #19 (comment) since this pull request was already open and you had already commented an alternate strategy. However, I did open pull request #23 following your suggestion.

@michaelwittig
Copy link
Contributor

#24 was merged as discussed in #28

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants