Skip to main content
reformatted code block
Source Link

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

In addition to your question: Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.

Another additional point: you would want to set up a proper paragraph in ~/.ssh/config along the lines of

´´´ Host ec2frontend HostName FillInThePublicIpAddress User ubuntu Port 22 IdentityFile ~/.ssh/FillInNameOfRSAPrivateKey TCPKeepAlive no ServerAliveInterval 15 ServerAliveCountMax 3 RemoteForward 80 localhost:80 DynamicForward 8108 ´´´

Host ec2frontend
    HostName FillInThePublicIpAddress
    User ubuntu
    Port 22
    IdentityFile ~/.ssh/FillInNameOfRSAPrivateKey
    TCPKeepAlive no
    ServerAliveInterval 15
    ServerAliveCountMax 3
    RemoteForward 80 localhost:80
    DynamicForward 8108

Whis allows a simple ssh ec2frontend to connect and reverse forward port 80.

And anothernother: You want to install autossh and use autossh -M 0 -Nf ec2frontend to have a permanent connection. autossh is in the ubuntu repos and after installing and called with the above command keeps the SSH alive (with a ping through the SSH tunnel) and restarts if necessary.

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

In addition to your question: Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.

Another additional point: you would want to set up a proper paragraph in ~/.ssh/config along the lines of

´´´ Host ec2frontend HostName FillInThePublicIpAddress User ubuntu Port 22 IdentityFile ~/.ssh/FillInNameOfRSAPrivateKey TCPKeepAlive no ServerAliveInterval 15 ServerAliveCountMax 3 RemoteForward 80 localhost:80 DynamicForward 8108 ´´´

Whis allows a simple ssh ec2frontend to connect and reverse forward port 80.

And anothernother: You want to install autossh and use autossh -M 0 -Nf ec2frontend to have a permanent connection. autossh is in the ubuntu repos and after installing and called with the above command keeps the SSH alive (with a ping through the SSH tunnel) and restarts if necessary.

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

In addition to your question: Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.

Another additional point: you would want to set up a proper paragraph in ~/.ssh/config along the lines of

Host ec2frontend
    HostName FillInThePublicIpAddress
    User ubuntu
    Port 22
    IdentityFile ~/.ssh/FillInNameOfRSAPrivateKey
    TCPKeepAlive no
    ServerAliveInterval 15
    ServerAliveCountMax 3
    RemoteForward 80 localhost:80
    DynamicForward 8108

Whis allows a simple ssh ec2frontend to connect and reverse forward port 80.

And anothernother: You want to install autossh and use autossh -M 0 -Nf ec2frontend to have a permanent connection. autossh is in the ubuntu repos and after installing and called with the above command keeps the SSH alive (with a ping through the SSH tunnel) and restarts if necessary.

added 846 characters in body
Source Link

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

In addition to your question: Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.

Another additional point: you would want to set up a proper paragraph in ~/.ssh/config along the lines of

´´´ Host ec2frontend HostName FillInThePublicIpAddress User ubuntu Port 22 IdentityFile ~/.ssh/FillInNameOfRSAPrivateKey TCPKeepAlive no ServerAliveInterval 15 ServerAliveCountMax 3 RemoteForward 80 localhost:80 DynamicForward 8108 ´´´

Whis allows a simple ssh ec2frontend to connect and reverse forward port 80.

And anothernother: You want to install autossh and use autossh -M 0 -Nf ec2frontend to have a permanent connection. autossh is in the ubuntu repos and after installing and called with the above command keeps the SSH alive (with a ping through the SSH tunnel) and restarts if necessary.

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

In addition to your question: Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.

Another additional point: you would want to set up a proper paragraph in ~/.ssh/config along the lines of

´´´ Host ec2frontend HostName FillInThePublicIpAddress User ubuntu Port 22 IdentityFile ~/.ssh/FillInNameOfRSAPrivateKey TCPKeepAlive no ServerAliveInterval 15 ServerAliveCountMax 3 RemoteForward 80 localhost:80 DynamicForward 8108 ´´´

Whis allows a simple ssh ec2frontend to connect and reverse forward port 80.

And anothernother: You want to install autossh and use autossh -M 0 -Nf ec2frontend to have a permanent connection. autossh is in the ubuntu repos and after installing and called with the above command keeps the SSH alive (with a ping through the SSH tunnel) and restarts if necessary.

Source Link

What you are looking for is the -R option or RemoteForward in ~/.ssh/config. See man ssh. I am a bit rusty on this one, but I think:

ssh -i ~/.ssh/yourAWSkey -R 80:localhost:80 ubuntu@PublicIpAddress

should expose any webserver on your Pi listening on port 80 to the PublicIpAddress of the AWS EC2 instance. ssh portforwarding is very powerful and extremely flexible.

Remote forwarding port 22 gives you ssh access to your Pi from the public internet but be careful - you miss SSH access to the EC2 server on port 22 (as long as the Pi is holding the connection). So you better do ssh -R 443:localhost:22. This will then forward any connection to PublicIpAddress:443 (the canonical HTTPS port) to the SSH port on the Pi.