Run Firefox over X11 over SSH / VNC on a cheap virtual machine
Posted Under: Internet,Linux,Server admin,Virtualization
To run over SSH: Not
This is how to run a Firefox browser on a cheap VPS machine (e.g. a Google Cloud VM Instance) with an X-server connection. It’s actually not a good idea, because it’s extremely slow. The correct way is to set up a VNC server, because the X server connection exchanges information on every little mouse movement or screen update. It’s a disaster on a slow connection.
My motivation was to download a 10 GB file from Microsoft’s cloud storage. With my own Internet connection it failed consistently after a Gigabyte or so (I guess the connection timed out). So the idea is to have Firefox running on a remote server with a much better connection. And then transfer the file.
Since it’s a one-off task, and I kind-of like these bizarre experiments, here we go.
These steps:
Edit /etc/ssh/sshd_config, making sure it reads
X11Forwarding yes
Install xauth, also necessary to open a remote X:
# apt install xauth
Then restart the ssh server:
# systemctl restart ssh
and then install Firefox
# apt install firefox-esr
There will be a lot of dependencies to install.
At this point, it’s possible to connect to the server with ssh -X and run firefox on the remote machine.
Expect a horribly slow browser, though. Every small animation or mouse movement is transferred on the link, so it definitely gets stuck easily. So think before every single move, and think about every single little thing in the graphics that gets updated.
Firefox “cleverly” announces that “a web page is slowing down your browser” all the time, but the animation of these announcements become part of the problem.
It’s also a good idea to keep the window small, so there isn’t much to area to keep updated. And most important: Keep the mouse pointer off the remote window unless it’s needed there for a click. Otherwise things get stuck. Just gen into the window, click, and leave. Or stay if the click was for the sake of typing (or better, pasting something).
Run over VNC instead
This requires installing an X-Windows server. Not a big deal.
# apt update # apt-get install xfce4 # apt install x-window-system
once installed, open a VNC window. It’s really easiest by clicking a button on the user’s VPS Client Area (also available on the control panel, but why go that far) and go
# startx
at command prompt to start the server. And then start the browser as usual.
It doesn’t make sense to have a login server as it slows down the boot process and eats memory. Unless a VNC connection is the intended way to always use the virtual machine.
Firefox is still quite slow, but not as bad as with ssh.
Reader Comments
Weird experience indeed :-)
While a simple curl or wget would have done the trick, probably?
Yours faithfully
Of course I would have used wget, had it been an option. The problem was that I had to login into the cloud storage with a browser and then download. Maybe I could have copied cookies and stuff after a session with a local browser, but I’m not sure that would have worked either.