1

In my organization of say 5, some times i need to give many people access to the same EC2 Instance. Sharing the private key and the password b/w 5 users is definitely not a good idea!(Also i don't want to share the original pem/ppk file)

So, how can i fix this problem?

Please help

4 Answers 4

2

"PACS" Puppet, Ansible, Chef, Saltstack.

I strongly suggest using Ansible as it has a user module built right into it, and you can get up and running super quickly!

1

Hi Guys Here is my steps what i did in my server

Step 0. Login by default user, “ec2-user”:

krishna@hostname:~/mykeys$ ssh -i my_key.pem [email protected]

Step 1. Create a new user, we will call our new user “krishna”

[ec2-user@ip-11-111-111-111 ~]$ sudo adduser krishna

Set password for “krishna” by:

[ec2-user@ip-11-111-111-111 ~]$ sudo su
[root@ip-11-111-111-111 ec2-user]$ passwd krishna

Add “krishna” to sudoer’s list by: if you want to give sudo access to krishna

[root@ip-11-111-111-111 ec2-user]$ visudo

and add this to the last line:

krishna ALL = (ALL)    ALL

Alright! We have our new user created, now you need to generate the key file which will be needed to login, like we have my_key.pem in Step 0.

Now, exit and go back to ec2-user, out of root.

Step 2. Creating the public and private keys:

[ec2-user@ip-11-111-111-111 ~]$ su krishna

Enter the password you created for “krishna” in Step 1.

[krishna@ip-11-111-111-111 ec2-user]$ cd /home/krishna/
[krishna@ip-11-111-111-111 ~]$ ssh-keygen -b 1024 -f krishna-t dsa
[krishna@ip-11-111-111-111 ~]$ mkdir .ssh
[krishna@ip-11-111-111-111 ~]$ chmod 700 .ssh
[krishna@ip-11-111-111-111 ~]$ cat krishna.pub > .ssh/authorized_keys
[krishna@ip-11-111-111-111 ~]$ chmod 600 .ssh/authorized_keys
[krishna@ip-11-111-111-111 ~]$ sudo chown krishna:ec2-user .ssh

In the above step, krishna is the user we created and ec2-user is the default user group.

[krishna@ip-11-111-111-111 ~]$ sudo chown krishna:ec2-user .ssh/authorized_keys

Step 3. Now you just need to download the key called “krishna” I use scp to download/upload files from EC2, here is how you can do it:

You will still need to copy the file using ec2-user, since you only have the key for that user name. So, you will need to move the key to ec2-user folder and chmod it to 777.

[krishna@ip-11-111-111-111 ~]$ sudo cp krishna/home/ec2-user/
[krishna@ip-11-111-111-111 ~]$ sudo chmod 777 /home/ec2-user/krishna

Now come to local machine’s terminal, where you have my_key.pem file and do this: download the key of krishna to local machine then change the mod to 600 by

krishna@hostname:~/mykeys$ sudo chmod 600 krishna

now its time to take remote of that server

krishna@hostname:~/mykeys$ ssh -i krishna [email protected]

Thanks Krishna

0

You can just create multiple users on Linux (http://www.tecmint.com/add-users-in-linux/). After that you can for example add a SSH key for each user in /home/USERNAME/.ssh/authorized_keys. If they need root rights, you can add them to the sudo group. If you need more specific rights, you could implement solutions like LDAP.

0

First generate a public/private key pair for every user. (In case they don't have one yet)

Then you can put each user public key into $HOME/.ssh/authorized_keys on your EC2 instance.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .