Tomer
Tomer

Reputation: 4481

SSH using pem file asking for password

I've been installing my production ENV on EC2, ubuntu. After couple of days playing with stuff (specifically) changing folder permissions, I suddenly realized, something went wrong with my default ubuntu user, and now when I am trying to

ssh -i production.pem [email protected]

It asks me for a password. I've tried modifying my ubuntu folder permission recursively back (or not back) to ubuntu, but it didn't work:

sudo chmod ubuntu:ubuntu .

Any idea what have I changed and how to fix it?

Thanks!

Upvotes: 0

Views: 1160

Answers (1)

Tomer
Tomer

Reputation: 4481

Here is what I did: SSH to the account using a different account and switched to the ubuntu user,

sudo su ubuntu

Made sure my ubuntu home folder is owned solely by the user:

sudo chown -R ubuntu:ubuntu /home/ubuntu

Gave all permissions to for the users to do anything:

sudo chmod 700 ~/.ssh

And (this is the most important part..), changed the .ssh folder correctly:

chmod 600 authorized_keys 
chmod 600 id_rsa
chmod 644 id_rsa.pub
chmod 644 known_hosts

Answered my own, but kept for future reference.. (It took me a while to figure:)
Good look.

Upvotes: 1

Related Questions