0

I just started working with AWS to create a wordpress site on an EC2 instance (using the tutorial at https://www.youtube.com/watch?v=4WR7EFFLF04). Everything was working fine until I tried to add an SSL certificate using another tutorial (I can't seem to find right now).

In following those steps, something broke the site (assumed DNS error) to where it wouldn't load because of too many redirects. When I went back through the tutorial to try to fix what I had done, I got to where it had me log in via SSH which I had previously done without any issues and I began getting a "Permission denied (PublicKey)" error.

Since then, I haven't been able to login to that instance or any other instances without getting the same error. I've even tried creating a new instance with a brand new key and I still get that same error. Any idea what could be going on?

UPDATE I did the debug command that Flos recommended and this is the output. (is this enough to bring it "on topic" and reopen the question?)

output:

OpenSSH_8.1p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug1: Connecting to ec2-13-59-207-225.us-east-2.compute.amazonaws.com port 22.
debug1: Connection established.
debug1: identity file /Users/bradley/Desktop/John and Rhonda Wordpress Files/keypair-2.pem type -1
debug1: identity file /Users/bradley/Desktop/John and Rhonda Wordpress Files/keypair-2.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Debian-10+deb10u2
debug1: match: OpenSSH_7.9p1 Debian-10+deb10u2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to ec2-13-59-207-225.us-east-2.compute.amazonaws.com:22 as 'admin'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:OiIQ5QiVxQvN9lAkjLm90ynddjDDs9L75PqDAL/cTv4
debug1: Host 'ec2-13-59-207-225.us-east-2.compute.amazonaws.com' is known and matches the ECDSA host key.
debug1: Found key in /Users/bradley/.ssh/known_hosts:6
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /Users/bradley/Desktop/John and Rhonda Wordpress Files/keypair-2.pem  explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/bradley/Desktop/John and Rhonda Wordpress Files/keypair-2.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
admin@ec2-13-59-207-225.us-east-2.compute.amazonaws.com: Permission denied (publickey).
Josiah Palmer
  • 151
  • 1
  • 16

1 Answers1

1

Are you sure you're using the correct identity/key, username and ip/dns?

Some distribution use ec2-user, ubuntu or admin as username.

Which OS is it?

Also have a look here

How do you connect?

I mostly just add an entry to my ssh config file ~/.ssh/config

Host router
   HostName 192.168.1.1
   Port 22
   User ec2-user
   IdentityFile ~/.ssh/router.pem

then I just type

ssh router
Flos
  • 21
  • 3
  • When I go to the instance, click connect and select the SSH client option, it says the username is admin. I've also tried every other name listed in the link you gave. The server template thing I used is Linux/Unix, Ubuntu 10 | 64-bit (x86) Amazon Machine Image (AMI) | Updated: 11/17/20 – Josiah Palmer Nov 25 '20 at 20:41
  • It must be, hostname/ip, username or key file. How do you connect? I mostly create an entry to my ~/.ssh/config Host router HostName 192.168.1.1 Port 22 User ec2-user IdentityFile ~/.ssh/router.pem then I just type ssh router – Flos Nov 25 '20 at 21:04
  • I'm not super familiar with SSH so pardon my lack of knowledge on terms lol. The way I connected before and have continued to try to connect is from the Mac Terminal app using the command: ssh -i "keypair-2.pem" admin@ec2-13-59-207-225.us-east-2.compute.amazonaws.com - this is a direct copy from the instance connect screen – Josiah Palmer Nov 25 '20 at 21:23
  • I wondered if it was an issue with the key pairs that amazon was generating so I also just generated a new key pair on my mac, uploaded the public key to AWS and created a new EC2 instance using it. I encountered the same error. Not sure if that info is helpful – Josiah Palmer Nov 25 '20 at 21:24
  • Maybe its the best, if you run ssh in verbose mode "-v" and add the result to your question. `ssh -v -i "keypair-2.pem" admin@ec2-13-59-207-225.us-east-2.compute.amazonaws.com` If you don't get it running, and the verbose output looks ok and everything is correct, username/ip/identity try a different ubuntu image. – Flos Nov 26 '20 at 12:09
  • I just updated the post with the results of the -v – Josiah Palmer Nov 30 '20 at 01:08