Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can connect to EC2 as ubuntu user but not as the user i created

Tags:

ssh

amazon-ec2

I created a new ebs backed EC2-instance and the necessary key-pair. Now I am able to connect to the instance as ubuntu user. Once i did that I created another user and added it to the sudoers list but I am unable to connect to the instance as the new user I created.

I get the following error. I am using the same key to connect with the new user i created. Can somebody help me. Am I missing something here?

Permission denied (publickey)"
like image 954
Sid Avatar asked Jun 14 '10 08:06

Sid


1 Answers

Okay I think i figured it out.

The first technique is to login by password. The idea is to login as the ubuntu user or root user and go to /etc/ssh/sshd_config file and turn the PasswordAuthentication to yes and run /etc/init.d/ssh reload

If you try to connect now you ec2 allows you to log with the password of the user that was created. Though this is not really secure.

Second is you create a key-pair and copy the id-rsa.pub file and move it to the /home/new-user/.ssh/authorized_keys file and change permissions to 600 and assign to the appropriate user(new-user in this case).

I found this to be amazingly useful http://blog.taggesell.de/index.php?/archives/73-Managing-Amazon-EC2-SSH-login-and-protecting-your-instances.html

like image 106
Sid Avatar answered Sep 18 '22 01:09

Sid