I accidentally deleted the Home directory with sudo rm -r ~
, when I try reconnecting the ssh returns
ssh -v key.pem ec2-user@PublicIP-address
ec2-user@PublicIP-address: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
I doubled checked everything, correct IP correct key.
I have also tried clearing my ssh-key -D
I have also tried making my own ssh-keygen and add into the ssh-add
I have also tried rebooting my remote computer
All of these leads to the same outcome
I can still connect the instance via the amazon web console, however I wont be able to do commands such as scp
anymore which is crucial for managing my site.
At this point I noticed that the Ec2 console shows [~bash4.2]
on the commandline input.
Next i tried recreating the home folder by:
sudo mkdir /home/user
cp -rT /etc/skel/ "$HOME"
chown -R ec2-user:ec2-user /home/ec2-user
rebooted the instance and tried again
I still get the same Permission Denied error however now the Ec2 console shows
[ec2-user@PrivateIPaddress]
on the commandline input which is an indicative I did something right. I am suspicious this might be related to permission conflict due to manually created HOME directory
But the reason I am here is clearly because I am stumped, I can see related question but never answers to this specific problem and I am asking for help. Thanks