How to ssh into ec2 instance running centos as a newly created user?
5,331
Solution 1
As Roman points out, you need to copy the public part of your key (usually ending .pub) to this file: /home/dummy/.ssh/authorized_keys:
scp id_rsa.pub [email protected]:/home/dummy/.ssh/authorized_keys
Note, youll probably have to create the .ssh folder in /home/dummy first.
Then make sure the authorized_keys file has the correct permissions:
chmod 600 /home/dummy/.ssh/authorized_keys
Also, just to be safe, set the Selinux context too:
restorecon /home/dummy/.ssh/authorized_keys
Solution 2
You need to add your generated key to the newly created user's authorized_keys
.
Related videos on Youtube
Author by
user784637
Updated on September 18, 2022Comments
-
user784637 over 1 year
I am able to ssh into an ec2 instance as the root user using the private key .pem that was generated when I created the instance.
$ ssh -i Desktop/key.pem [email protected]
I then created a new user
$ useradd dummy
When I run the following command to sign in as the dummy user
$ ssh -i Desktop/key.pem [email protected]
I get the following error
Permission denied
How do I ssh into the new instance as the dummy user?
-
user784637 almost 11 yearsI am still getting the same error. I followed your instructions exactly. EDIT Setting the permissions to 700 on .ssh on the remote server resolved it.
-
Wiesław Herr over 9 yearsHad the exact same problem today, restorecon saved me. Thanks!