I’m trying to log in to a particular user on my lightsail account via ssh but I get a permission denied (public key) error
Here are the steps I followed(I am on git bash on windows 8)
ssh into my lightsail account via the .pem key provided via aws
ssh -i <key.pem> ubuntu@<public_ip_address>
(I am now logged in to my lightsail server)
sudo adduser user1
sudo touch /etc/sudoers.d/user1
sudo nano /etc/sudoers.d/user1
** user1 ALL=(ALL:ALL) ALL**
su - user1
sudo mkdir .ssh
sudo touch .ssh/authorized_keys
I open Another shell prompt and do the following
–ssh-keygen
–cat <file_location_of_key>.pub
-copy the contents
- paste the contents of the public key created on my local machine via ssh-keygen
- sudo chmod 700 .ssh
- sudo chmod 600 .ssh/authorized_keys
- sudo service ssh restart
- exit
I exit from the lightsail account and try to ssh to the grader user
ssh -i <file_location_of_key> user1@<public_ip_address>
I get the error Permission denied (publickey).
Note: I havn’t changed any port setting yet. I’m still trying to connect it to my default port 22
Advertisement
Answer
@RickBaker @helloV Thanks for your help. Realised the file was still owned by root. Had to change to ownership of the file to user1. ssh works fine now