I am trying to access a home desktop computer (A), from my laptop (C), through an EC2 instance (B). I have successfully set up many different kinds of tunnels and SSHed to my heart's content from (A) to (B), and back and forth between (B) and (C). I am so close to tunnelling straight from (A) to (C) but I keep getting the same error message.
So if: Me (A) ------> EC2 (B) ------> Target (C), I'm trying to tunnel straight from (A) to (C).
On the desktop (C), I run
ssh -N -R 52.60.xx.xx:1338:localhost:22 userB@machineB and this seems to work fine, creating a tunnel and forwarding port 1338 on (B) back to itself (C).
Then on (A), I run
ssh -p 1338 userB@machineB -o IdentitiesOnly=yes -i ~/.ssh/keyToMachineC_rsa and it seems to almost work.
-v flag I get a lot of output, but it seems to be connecting to the target machine (C) but then rejecting the key! The last several lines of the output look like this:
debug1: Host '[52.60.xx.xx]:1338' is known and matches the ECDSA host key. debug1: Found key in /Users/<Me>/.ssh/known_hosts:35 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/<Me>/.ssh/keyToMachineC_rsa debug1: Authentications that can continue: publickey debug1: Trying private key: /Users/<Me>/.ssh/keyToMachineB_rsa debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey).
It looks like it's offering machine (C) the correct key but still being denied! I have manually place the correct matching public key in the
~/.ssh/authorized_keys on machine (C)—in fact, I've created new key pairs several times and tried with different keys, always with this same result. The permissions on
~/.ssh/authorized_keys on (C) are tightened down and they are all owned by the right user. I have all of the relevant settings that I could find in
sshd_config completely open on (B) and (C), and in my AWS console.