I'm trying to set up an SSH Reverse Tunnel using Ngrok. I've generated a new SSH key and added it to my Ngrok SSH keys. However, when I attempt to run the command 'ssh -R 443:localhost:80 [email protected]', I keep running into a 'Permission denied (publickey)' error. Any advice on how to fix this?
2 Answers
The 'Permission denied (publickey)' error indicates that Ngrok isn't recognizing your SSH key. First, ensure that your private key matches the public key you added and check the permissions. Run this command to set the right permissions:
chmod 600 ~/.ssh/ngrok_key
Then, when connecting, use:
ssh -i ~/.ssh/ngrok_key -R 443:localhost:80 [email protected]
If you're still facing issues, consider regenerating your key in Ngrok and trying again.
Don't forget to use the -vv flag when connecting. It helps you see what keys are being loaded and gives you insight into the connection process.
Thanks! Using the private key finally resolved my issue. Here's the [link](https://stackoverflow.com/questions/48328446/id-rsa-pub-file-ssh-error-invalid-format) that guided me through it.

Thanks! I checked the permissions, but I still got an 'invalid format' error. I realized I was using the public key instead of the private key in my command. Here’s a link that helped me: [Invalid Format Error](https://stackoverflow.com/questions/48328446/id-rsa-pub-file-ssh-error-invalid-format)