1

I have an AWS cloud server that runs linux, to which i connect from my home computer. So far I used to use Putty to connect to it (Windows) but I just switched to Linux for my home computer.

I am trying to figure out how to create a tunnel while using a private key to connect through ssh.

The example on the different doc website is pretty straightforward:

To connect to the remote server:

ssh -i <key_file> user@xx.xx.xxx.xxx

This does work.

However to create a tunnel the doc mentions

ssh -L8080(portnumber):user@xx.xx.xxx.xxx:8080(remoteport)

But there isn't any mention of how to create a tunnel using a private key as in the first example.

I tried ssh -i <key_file> -L8080(portnumber):user@xx.xx.xxx.xxx:8080(remoteport)

but it didn't work.

Can anyone provide the correct command to create the tunnel while using a private key? Thanks!

5

You're conflating the port forwarding with the host (to connect to).

Formula is simply:

ssh user@host -i keyfile.pem -L 1234:127.0.0.1:2345
  • "conflating" = combine (two or more texts, ideas, etc.) into one. (sorry, not native english) – DependencyHell May 8 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.