Use real browser instead of w3m on SSH connections

I am using Ubuntu as desktop and server OS. When I am logged in to the server via ssh on terminal and have to view a web-page (localhost) on the server I use w3m (w3m localhost).

Unfortunately w3m is not that easy to handle, as the page has some big menus and uses jQuery. So I am wondering if it is possible to use a browser on my Desktop to connect to the server via SSH with a real browser (Firefox or Chrome).

Basically it would require to connect with a browser on my desktop to the server over SSH with username and password, and open on that server localhost.

Is this possible by default, or are there any add-ons for Firefox/Chrome? I would prefer Firefox.


Solution 1:

Use ssh port forwarding.

Connect to the remote server with something like this:

ssh -L 8080:localhost:80 user@remoteserver

Now, point your local browser to localhost:8080. It should be forwarded to localhost:80 in the remote server.

Solution 2:

PART 1

Make a socks proxy with ssh!

ssh -D 9999 user@remoteserver

Now open your Firefox preferences, go to Advanced > Network > Settings. Select Manual proxy configuration. Put localhost for the SOCKS Host, put 9999 for the port. Test it by going to http://whatismyip.org or some similar site.

Because you said you're trying to access a web page at localhost (relative to your server), you may not want to exclude localhost and 127.0.0.1 from using the proxy. Of course, you could just use the local ip of the server..

If you don't like my explanation, these links jogged my memory while writing this:

http://linux.die.net/man/1/ssh

http://embraceubuntu.com/2006/12/08/ssh-tunnel-socks-proxy-forwarding-secure-browsing/

https://calomel.org/firefox_ssh_proxy.html

PART 2

The error you got, channel 3: open failed: connect failed: Connection refused has absolutely nothing to do with ssh. Apparently you're trying to access some mysql thing. This has an extra challenge, because mysql blocks access from ssh tunnels by default. I don't do mysql, so I don't know what I'm talking about for the rest of this. I'm just quoting the relevant bits of the link at the end, which you should read.

Open /etc/mysql/my.cnf and look for the [mysqld] section. If you see a line "skip-networking", comment it. Add "bind-address = 127.0.0.1" (without the quotes, of course).

http://www.debuntu.org/port-forwarding-and-channel-3-open-failed-connect-failed-Connection-refused

Part 3

Javier's solution ssh -L 8080:localhost:80 user@remoteserver is fantastic if you just need access to the one location. It lets you access localhost, and leaves the rest of your internet alone. My solution with ssh -D goes farther, and will actually direct all of your http requests to the remote server. Obviously you might not actually want this. But I've found it useful when I wanted http access to all machines on a network, or when I didn't want my http requests going through the network I'm wired into (ie, online banking at starbucks. All my traffic goes through the ssh tunnel to my home internet.)

Solution 3:

You can use X forwarding through SSH so that any X applications that you run on the server would show up on your personal computer.

  1. When connecting with SSH to the server, add the -X flag. For example, ssh -X myserver.
  2. Install a GUI browser on the server and simply run it. The output will appear on your personal computer through X forwarding and the secure SSH connection.