0

From this and this I've gathered that I should ssh into my ec2 instance from my Mac by:

ssh -C -c blowfish -X -i user.pem user@hostname.com

This accomplishes X11 forwarding.

Afterwards, how do I preview an /path/to/index.html file in chrome or any web browser?

ehacinom
  • 115

1 Answers1

2

For viewing plain HTML files on the local browser, you can use SFTP. Open the file browser (Nautilus) and go to File -> Connect to a server. The address will look like: sftp://user@hostname.com. You'll have to add your identity to the SSH agent (ssh-add user.pem) for key-based login to work correctly. Once connected, navigate to your HTML file and open them.


With X11 Forwarding, you can do this:

ssh -C -c blowfish -X -i user.pem user@hostname.com
# On the remote shell
firefox /path/to/index.html &

Firefox will open on your local system, but will actually run on the server.


A third option, if you're willing to set up a static web server, is to set up port forwarding and then open it in your local browser:

ssh -C -c blowfish -X -i user.pem -L 9000:localhost:9000 user@hostname.com 'cd /path/to/; python3 -m http.server 9000'

Then, in your local browser, open http://localhost:9000.

muru
  • 197,895
  • 55
  • 485
  • 740
  • Thank you for starting with the basics! However, I need to clarify -- there's no file browser. The files are on a remote instance that I interact with through command line. To open files from that remote machine in a texteditor on my local machine, I set up a reverse SSH tunnel. Is there a way to do the same except with a web browser? – ehacinom Sep 11 '14 at 18:13
  • @hiyume Everything I'm talking about is done locally - in your laptop/desktop. Does it not have Ubuntu? – muru Sep 11 '14 at 18:15
  • okay, whoops, I think I asked this question wrongly. the local machine doesn't have ubuntu, only mac, which means the question probably doesn't belong here. Interesting, everything must be done locally. – ehacinom Sep 11 '14 at 18:23
  • @hiyume then you can try at [apple.se]. – muru Sep 11 '14 at 18:24
  • I will figure out how to configure ssh on my local machine so this will work. After forwarding X11, though, do you just open the html file and it opens a web browser page? (if so, nice!) – ehacinom Sep 11 '14 at 18:24
  • you're wonderful, that was very clear :) – ehacinom Sep 11 '14 at 18:27
  • @hiyume one more option added. – muru Sep 11 '14 at 18:30