15

I am converting an old laptop into what will basically just be a terminal for some of my other computers. For the most part, I only need to ssh into my computers, and that I can do with any CLI-based OS.

If that was all I needed, I would just install Debian and be done with it. But I also have a couple of computers that have built-in browser-based interfaces, such as a TrueNAS machine. I have a Fedora machine that has a "cockpit" also. I could install a desktop environment GUI, and simply open the interfaces in a browser, and in fact I do that currently and it works fine. But the whole desktop environment seems like way overkill for what I need.

So, what is the simplest/lightest/fastest way in which I can access a browser-based interface, but otherwise maintain as close to a CLI-only system as I can?

Shadow The GPT Wizard
  • 587
  • 2
  • 11
  • 29
Valiant
  • 161
  • 1
  • 6
  • 1
    Forgive my ignorance - do you mind expanding on why you want to use a browser interface from the device's terminal rather than access it from your phone or another connected desktop device ? Is it to avoid the configuration or connectivity necessary to make that happen ? – aaaaaa Aug 04 '23 at 19:07
  • @aaaaaa I like having a single computer to access my machines, and I end up googling on my phone often at the same time. It's just an efficiency thing, not so much a technical challenge. – Valiant Aug 05 '23 at 00:05
  • 2
    Sounds like what you really want is a Chromebook. – Mark Ransom Aug 05 '23 at 02:45
  • You just need to install a web browser. Lynx is an obvious choice; there are probably others. – Toby Speight Aug 05 '23 at 08:26
  • Not sure how it'd fit your need but blind people don't use GUI (for obvious reasons). They read the text using a device. Now, that device simply renders the page as text with relation to the HTML tags emphasized. This assumes that the page is A11Y compliant, which many pages aren't, especially the older ones. – Konrad Viltersten Aug 05 '23 at 15:21
  • There were web browsers before Mosaic (the first graphical one). Non-graphical ones still exist. – John Bollinger Aug 06 '23 at 02:23
  • If the machine you use to access this one has X11 installed you can use ssh -X or ssh -Y to have the windows open on your local machine. – Thorbjørn Ravn Andersen Aug 06 '23 at 08:31

4 Answers4

34

I'd want to test out the actual apps I'd use before deciding. My highest common factor tool for accessing a web page over a terminal is carbonyl - I run the binary not the docker container, and the 'advantage' is even modern web pages work. And that tab you see on top is not my browser, it is my terminal window.

enter image description here

And it dosen't need a full DE as far as I can tell, its entirely frambuffer based

Its still a little work in progress - one needs to ctrl-c to close a window, no tabs, and its just got a barely functional address bar, but where it shines, it shines.

Journeyman Geek
  • 127,463
  • 52
  • 260
  • 430
  • 1
    I will have to give this a go! I am going to be using FreeBSD, so I'll have to investigate how compatible that will be with it, but if it works, this sounds like exactly what I'm looking for, thank you! – Valiant Aug 04 '23 at 06:39
  • 1
    Okay, gotta say that's pretty awesome. – marcelm Aug 04 '23 at 15:17
  • 3
    Same thing, but Firefox instead of Chromium: [Browsh](https://github.com/browsh-org/browsh). Not as lightweight as carbonyl though, from what I'm reading – Clockwork Aug 04 '23 at 15:26
  • 1
    IIRC Browsh still needs a full graphical environment on the server and more importantly is covered by another answer. – Journeyman Geek Aug 05 '23 at 02:29
  • Is the pixellated look because it's emulating graphics with block mode characters? – Mark Ransom Aug 05 '23 at 02:51
  • Yup! It *is* somewhat gloriously Janky... amusingly, It reminds me of those old teletext systems from waaaay back – Journeyman Geek Aug 05 '23 at 02:53
  • Carbonyl is not even based on framebuffer, it is based on [Unicode characters](https://fathy.fr/carbonyl). For multiple tabs, you can use GNU screen or tmux. – niutech Aug 06 '23 at 23:20
21

There is the option of using the text based Web browser Lynx.

enter image description here

Depending on the functions you need it may still work, though obviously images and potentially a lot of HTML5 and javascript features are out. If all you need to view text only websites then it may at least be functional.

An alternative modern option is Browsh which takes in proper webpages and renders them to text for display in CLI tools such as ssh. It is intended for low bandwidth situations, and requires a sever have a full desktop with Firefox installed, but the machine viewing it could conceivably be CLI only.

Mokubai
  • 89,133
  • 25
  • 207
  • 233
  • 3
    I actually do use lynx quite often when I'm doing browsing via cli only systems! It's cumbersome for real googling, but it does the trick if I know exactly what I'm looking for. Unfortunately, I am hoping to take advantage of graphical elements for this particular purpose, so lynx won't help me for a lot of it. – Valiant Aug 04 '23 at 06:15
  • 4
    @Valiant If you want to use graphical elements, it's advisable to avoid using a text terminal for that purpose. Lynx and Links web browsers are more likely to provide a better experience when your website is designed to be accessible enough to function in a text-based environment. For websites that aren't accessible, it's usually better to use a conventional graphic web browser instead. – pabouk - Ukraine stay strong Aug 04 '23 at 16:11
  • 1
    w3m is also a decent text-based browser. Emacs also has a built-in Web browser called EWW, which can be used in a text console (there is also a third-party package for Emacs which wraps w3m) – Warbo Aug 05 '23 at 11:38
15

the whole desktop environment seems like way overkill for what I need.

It's not. It's probably more efficient even for SSH than any alternatives (of which there aren't many), but it's pretty much the only option for browsers – practically all of them are X11 programs, so you need to run them on an X11 display server, which means running Xorg.

Keep in mind this is Linux – the actual desktop environment does not need to be full 3D-accelerated KDE or GNOME; you can manually assemble a basic environment that consists of a window manager such as Openbox (or twm or Fvwm if you want it to look more retro) and some Xterm windows.

Although these days, Linux uses kernel mode-setting for most (even old) graphics controllers, which means initializing Xorg takes less than a second as the GPU is already configured, unlike in the old days where Xorg itself had to do it from scratch. That is, it is quite possible to stay in the console most of the time and startx whenever needed, exiting Xorg when no longer needed.

However, I would not recommend that; the Linux kernel's built-in console is slow and inefficient (among other problems) and probably the worst choice there is for daily use. You'll have a much better experience SSHing from xfce4-terminal or Xterm or something such.

But in any case, the browser – not the rest of the GUI! – will be the most inefficient part. Modern browsers and webapps are large; you could try Ladybird as it's getting close to usable, but trying to load a massive JavaScript-driven GUI in modern Firefox or SeaMonkey will be probably 80% of your battery usage. Trying to do it in something else than Xorg won't really change much.

(I mean, you could probably go all the way with the "terminal" setup and use your laptop as a VNC terminal to connect to a browser running on another machine...)

u1686_grawity
  • 426,297
  • 64
  • 894
  • 966
  • I’d like to add that what meshes best with kernel mode-setting and whatnot is Wayland. Using a lightweight compositor/window manager like Sway would be my modern go-to choice here. – Daniel B Aug 04 '23 at 05:51
  • @DanielB: Sway requires driver features (dma-buf at least) that are often unavailable on old systems, while Xorg generally runs out of the box. (Depends on what counts for "old" for OP, of course, but there are plenty 32-bit laptops that will happily run Xorg but not anything wlroots-based.) – u1686_grawity Aug 04 '23 at 05:57
  • This is an interesting perspective, thank you! I plan on using FreeBSD for this, which obviously doesn't come with anything graphical. I will obviously have to install xorg for any potential option I choose. Can a lightweight minimally featured browser run out of xorg by itself? Out of a basic window manager? Or do the most basic browsers still require a full desktop environment (I would probably choose xfce out of light weight interests)? Are there still negligible performance gains between those different options? – Valiant Aug 04 '23 at 06:09
  • @Valiant: Browsers do not really interact with the desktop environment much, as long as you don't attempt to use the few features that need it by their nature (e.g. screen sharing). You _will_ need a window manager of some sort, as otherwise you literally cannot manage windows at all (i.e. no moving, no resizing), the other components are up to you. – u1686_grawity Aug 04 '23 at 06:16
  • @Valiant Browsers are almost never dependent on the exact environment these days on UNIX-like systems, provided the underlying display stack is supported. Also, I second the suggestion of just using a minimal GUI and terminal emulators instead of the OS-provided virtual console. It needs a bit more RAM and CPU time, but you get many, many benefits out of it, such as copy-paste functionality just working without any special setup. I practically live on the command-line on UNIX-like systems, but still preferentially use a setup like this instead of working from a true text console. – Austin Hemmelgarn Aug 04 '23 at 13:24
  • So you're a fellow SeaMonkey user? – Neil Aug 05 '23 at 00:16
  • Agreed that the _desktop environment_ is totally unnecessary; you don't need much more than an X server and window manager to run X11 programs. – Toby Speight Aug 05 '23 at 08:29
3

You can use another system that does have a GUI interface and browser, utilizing an SSH tunnel on the terminal system as a proxy. First, set up the SSH service/daemon on your terminal system.

The question isn't entirely clear about why you want to set up a CLI system to access your other computers, so it's plausible that you're connecting to it remotely, so let's assume for the sake of argument that this approach makes sense for your use case. If not, maybe someone else will find it helpful.

To do this, your client needs to support setting up forwarding. I'll use the SSH command-line utility as an example.

One option is to set up a single port for forwarding, like ssh -L LOCAL_PORT:HOST:HOST_PORT [USER@]SSH_SERVER, and connect your browser to http://localhost:LOCAL_PORT. For HTTP, you want port 80, and for HTTPS, port 443. Note that if it's HTTPS, the browser will reject the certificate for having the wrong domain name, but you may still be able to proceed anyway.

Alternately, if your client supports it, you can set up a SOCKS proxy using dynamic forwarding, like ssh -D LOCAL_PORT [USER@]SSH_SERVER. Then configure your system or browser to use that local port as a SOCKS proxy. Using this method, a browser will accept a valid, HTTPS certificate. Enter the original URL as you would enter it if browsing to it from the terminal system (the SSH host).

my browser proxy configuration

Corrodias
  • 479
  • 2
  • 9