Article 4SP6Z Permission denied (publickey).

Permission denied (publickey).

by
ivonak
from LinuxQuestions.org on (#4SP6Z)
Hello, I'm trying to write a script just to practice for my job, and I'm stuck on these tasks:
-As administrator I will run the web service by the user "wwwuser1"

-As administrator I will ensure that no other user on the server (except wwwuser1 & root) will be able to get the data neither to control the web server at ssh session.

-As administrator I will allow users to ssh to the system only by a key pair (no username & password)

I'm connected to my ec2 instance with ubuntu@publicIP
As I understand I need to make a new user (wwwuser1) and I need to be able to ssh with it to that instance.

So I tried to do this:
Code:sudo adduser wwwuser1 --disabled-password
sudo su - wwwuser1
mkdir .ssh
chmod 700 .ssh
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keysand then:
Code:ssh-keygen
cat ~/.ssh/id_rsa.puband then I copied the output in the .ssh/authorized_keys file and saved it, and after that I'm not able to ssh into my EC2 instance with wwwuser1, I got error saying: Permission denied (publickey).

I'm not really sure what to do.. I've been trying to figure out what is the problem but I can't.. everything that I googled ended up saying that I just need to do this and it will work, but it's not. :confused:latest?d=yIl2AUoC8zA latest?i=O-zRP8Q-m6I:N9Pv2eptVQs:F7zBnMy latest?i=O-zRP8Q-m6I:N9Pv2eptVQs:V_sGLiP latest?d=qj6IDK7rITs latest?i=O-zRP8Q-m6I:N9Pv2eptVQs:gIN9vFwO-zRP8Q-m6I
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments