Permission Denied(publickey)

After command -
ssh ubuntu@13.126.57.75 -L8888:localhost:8888
i am getting this error message- Warning: Permanently added ‘13.127.164.199’ (ECDSA) to the list of known hosts.
Permission denied (publickey)
I have tried the solutions given in other threads but nothing is working.
Help me.

Check your .pem file and do SSH correctly

I have .pub file and following the 2nd course on DL

Please specify what you tried and what didn’t work. Basically there are a number of reasons you might hav this problem.

  1. The permission of your .pem key or .pub file is too open. - Change it by chmod 400 <.pub or .pem file>
  2. The problem is in ssh and not in tunneling of the ports. So first get this command to work ssh ubuntu@13.126.57.75.
  3. We generally use .pem file and use ssh as ssh -i <pem key> ubuntu@<ip address>. You seem to have a slightly different pattern. You are using your public key to ssh. That’s OK if you already added your public keys to the authorized keys in the remote machine.
  4. This is a general problem of logging into Remote machine. You might find a number of posts on StackOverflow on this.

Finally, do ssh -v <rest of your command. This will give verbose output that will help you understand the issue and also post it here or in Stack Overflow (which is better for this problem).

I had a similar error message, as I didn’t know my SSH passphrase.
Solution: Platform: GCP ✅