0

I am trying to connect AWS and I am getting the following error:

Permission denied (publickey).

The only things I have are:

  • User Name
  • Host
  • a 20 char Key

I am running the command ssh -i <KEY> user@host

Volatil3
  • 14,253
  • 38
  • 134
  • 263
  • Which image ? are you trying to connect with the pem file ? – Amit Baranes Oct 15 '19 at 10:26
  • Possible duplicate of [AWS SSH connection error: Permission denied (publickey)](https://stackoverflow.com/questions/23392763/aws-ssh-connection-error-permission-denied-publickey) – Adiii Oct 15 '19 at 10:33

2 Answers2

1

Perform below steps,

 sudo chmod 400 <KEY-NAME>.pem
 sudo ssh -i "<KEY-NAME>.pem" <username>@<host>

Make sure username is right one as username can be root, ec2-user, ubuntu etc.

if it doesn't solve your issue then please share information with debugger by running ssh command with -vv.

 sudo ssh -i "<KEY-NAME>.pem" <username>@<host> -vv
Skywalker
  • 41
  • 6
0

For me editing the ssh configuration file and changing PasswordAuthentication no to PasswordAuthentication yes worked. So just type:

sudo vim /etc/ssh/sshd_config

Edit the file and then restart ssh service:

sudo service ssh restart

Then you will able to login with any created user without using the pen certificate that is only intended to login as ubuntu user (i.e. similar to root).

Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
K. Stopa
  • 597
  • 8
  • 9