web stats
Amazon EC2 Instance Assign New User Key Pair on Linux Instance | Why Cloud Computing

Amazon EC2 Instance Assign New User Key Pair on Linux Instance

Sometimes it is not good to share your primary linux account details (i.e ubuntu or ec2-user) to some third party people. In that case you might need an individual account created for them along with a keypair. This amazon ec2 instance guide will help you assign a new user key pair for a particular user without setting sudoers permissions. Please not that this guide is totally focused on linux instance but with few tweeks, it should also work on windows instance too.

Share our stuff and help us grow. Need help to create something new or fix something old? Contact us to know if we can help 🙂

Create the new user and enter the password. I hope you are aware of that. Now, get into the new user after entering the password.

su NewUser
#Enter the password

Go to the home director and use ssh-keygen to create public and private keys for that particular user.

cd ~/
ssh-keygen -b 1024 -f NewUser -t dsa

If you don’t have .ssh directory, create one and change permissions to 700. This is important, you don’t want somebody else to access the new user .ssh directory.

mkdir .ssh
chmod 700 .ssh

Now send the NewUser.pub to authorized_keys and change its permissions to 600.

cat NewUser.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

Change the owner to new users for both .ssh and authorized_keys.

chown NewUser .ssh
chown NewUser .ssh/authorized_keys

So, that basically ends the setup on the server side. Now, its time to configure the clients machine from where you wish to connect.

If you want to connect to the remote server using another linux machine. Check the following. Steps for connecting via windows machine are mentioned below.

From home directory of the user from the first server get the NewUser file. Rename it with .pem extension.

mv NewUser NewUser.pem

Move this file to remote client server and change the permissions.

chmod 600 NewUser.pem

Now use the following command to connect to that user.

ssh -i /path/to/file/NewUser.pem OR

If you want to connect to the server using windows machine.

Use the puttykeygen and load “existing private key” and generate .ppk file (save private key) and use putty to connect.

Hope the setup helped.

Reference docs.

http://www.curvve.com/blog/guides/2013/how-to-create-multiple-amazon-ec2-keypair-logins-for-contractors-and-employees/

https://sites.google.com/site/microbasegrid/developer-documentation/tutorials/system-administration/uploading-your-own-ssh-key-to-amazon-ec2

Share our stuff and help us grow. Need help to create something new or fix something old? Contact us to know if we can help 🙂

Related Posts:

  • No Related Posts

One Response to Amazon EC2 Instance Assign New User Key Pair on Linux Instance

  1. Ingo says:

    Great stuff, thanks for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *

Why ask?