linkedin
  • Become a Seller

How to resolve 'Permission denied (publickey)' or 'Authentication failed, permission denied' errors when accessing the EC2 instance?

Harshdeep Singh . Sep 20, 2023

A:

Here are some methods you can try to resolve the 'Permission denied (publickey)' or 'Authentication failed, permission denied' errors

  1. Verify the User Name: Ensure that you’re using the correct user name for your AMI.
  2. Check File Permissions: Verify that the file permissions within the operating system are correct and that the correct SSH public key is in the authorized_keys file.
  3. Enter Key File Password: Enter the password for your key file or use ssh-agent to load the key automatically.
  4. Check Instance’s Permissions: Check that the instance’s permissions are correct and the correct SSH public key is in the authorized_keys file.

If you copied your SSH keys from another source, you might encounter a permission denied error. This can happen if the file permissions on the SSH keys are too open. It’s simply not allowed to have 777 permissions on the public or private keys. You can set the following permissions on the ssh directory and its files:


.ssh directory: 700 (drwx------)

public keys: 644 (-rw-r--r--)

private keys: 600 (-rw-------)

authorized_keys: 600 (-rw-------)

known_hosts: 600 (-rw-------)

config: 600 (-rw-------)

You can change these permissions using chmod command.

If these methods don’t work, you might need to check your SSH configuration file or restart your SSH service.

Sep 20, 2023

Was this helpful? upvote icon 2 downvote icon 0
img

Did not find the question you are looking for?

Get fast answers from real users and our software experts

menlaptop

Have a Question in Mind?

Get answers directly from verified users and our software experts

Software icon representing 20,000+ Software Listed 20,000+ Software Listed

Price tag icon for best price guarantee Best Price Guaranteed

Expert consultation icon Free Expert Consultation

Happy customer icon representing 2 million+ customers 2M+ Happy Customers