Some Bits: Nelson's log

6 posts about plex

Accessing Plex containers for Claude

I have like 20 containers in Proxmox now doing various services. I used to use Tailscale to access them all but my tailnet was getting cluttered up with stuff that only needed to be reachable for admin purposes, not regular use. This got untenable using Claude to do admin work.

The setup Claude came up with just requires LAN or Tailscale access to the proxmox host (pve). It then jumps through that via ssh to the each to container via a LAN connection. One added complication: Claude has to use an HTTP proxy for any ssh at all.

sandbox → HTTP proxy → claude@pve (over Tailscale) → ProxyJump → root@192.168.0.99:22 (the container)

Claude has its own ssh key that it’s managing. I am trusting this key with limited access to PVE and then full root access on the container. Scary but so far so good!

On PVE, Claude has a user account with a restrictive authorized_keys for Claude’s key. It limits what the key does to just proxying ssh PVE to the container. There’s one line like this for each container.

restrict,port-forwarding,permitopen="192.168.0.99:22",command="/bin/false" ssh-ed25519 AAAA… claude@desktop foo

On the container, root’s authorized_keys allows Claude in with full access.

In Claude’s shell environment, it has an SSH config with stanzas like this:

Host example
  HostName 192.168.0.99
  HostKeyAlias example-ct317
  User root
  ProxyJump pve

ProxyJump is a bit of ssh config magic that simplifies the process of sshing first into once place and then onto a second.

(I’m skipping over the details of how Claude uses the HTTP proxy to connect to PVE in the first place. This is necessary for any ssh at all to work, Claude Code seemed to have a solution for that workaround.)

This all seems baroque as I’m typing it all out (myself, not Claude) but it’s quite simple. Bottom line: Claude gets full root access to a container behind a firewall without tailscale on each container. Instead we use Proxmox as an ssh proxy but Claude only has minimal permissions on the Proxmox host.

Updating Plex in Linux (NixOS)

Major Plex exploit this week shows out a bunch of older Plex servers that weren’t updated. Turns out Plex server does not auto-update itself in Linux. It does on Mac and Windows. But in Linux you’re expected to update it yourself through your OS.

I used to run Plex server on Debian. Updating there was as simple as an apt upgrade. But you’d still have to remember to run that, I’m not sure unattended-upgrades covered it.

I’m now running Plex server on NixOS. Entirely with Claude Code’s help managing Nix. We came up with several ways to update it, none entirely satisfactory:

  1. Install Plex from nixpkgs, either stable or unstable. You can run system.autoUpgrade and have NixOS update itself on a timer. This works but updates tend to be a little behind: nixpkgs is a few weeks behind Plex releases. The crucial security fixes did come out in a timely fashion.
  2. Install Plex with Nix yourself from a hand-rolled file that grabs a pinned Plex server .deb and installs it in NixOS. This is a little tricky because of Nix’ assumptions about paths, Claude ended up creating a bubblewrap environment for it. The problem is for new Plex releases you have to repin, run a Nix update yourself from your dev environment, rebuild and switch.
  3. Don’t install Plex with Nix. Instead make a generic NixOS container that manages everything except Plex’s own program files. Then have that container launch a script to download and install Plex in /var/lib in the NixOS container. Also an update script that downloads new versions and installs them on its own.

There’s a similar question with Plex’ config file, the Preferences.xml. Claude started wanting to manage that itself as part of the Nix config. But that means the Plex GUI for editing the config would be overwritten by new Nix pushes. The other option is just to keep it as a file outside of Nix on the server.

I started with option 2 (my Nix config doing the work). I quickly got irritated at how much work I had to do to push an update. So now I’m in option 3. I lose Nix management of Plex and its config file. But Claude’s own script can handle upgrades for me, it seems like a reasonable design. We’ll see in a few weeks.

Option 1 is probably the simplest and most reasonable. I went with 3 because I wanted updates ASAP.

TCL Roku vs Plex subtitles

Finally fixed an annoying problem where Plex subtitles wouldn’t show on my TCL TV (which runs Roku OS).

The solution is in the TCL TV settings, under “Accessibility / Captions mode”. Set it to “Off” (or maybe “On Always”). If you have it set to “On replay” or “On mute” then the subtitles Plex puts in a subtitle stream for the TV won’t display. (I suspect the TCL setting is overriding the stream.) I found this solution here.

There’s a different solution I found on Reddit that no longer seems to work. That has you setting the Plex app settings, to turn subtitles to “Roku captions mode”. Despite the Plex support docs describing this, my Plex app (version 7.14.6) does not have a Settings menu at all.

A third workaround is to tell Plex to “burn subtitles always”. But that has the server transcode the video and render the subtitles into pixels on the video stream. It’s much better to have Plex send a separate subtitle stream and let the TV do the rendering.

Proxmox what I installed

Following on my general post about Proxmox here’s a list of specific things I installed on my new home LAN server. As always this blog is mostly written for my own notes, but maybe other folks will find it interesting where I ended up.

Proxmox hypervisor

In general the idea is to customize the Proxmox host itself as little as possible, all my stuff should be going in guest operating systems. But Proxmox itself is a full Debian system with super cow powers and you can install other stuff. I kept it to a minimum just for administering the hypervisor:

  • apt install stress-tui stress-ng lm-sensors hwinfo joe sudo
  • Tailscale so I can access the management GUI from anywhere
  • The user “nelson” with my usual environment. Not really necessary.

I hand-mounted a USB disk of my media files by editing /etc/fstab. Proxmox seems to have no tool for managing USB disks. It doesn’t even automount them although I bet there’s some Debian thing you can install for that. As always be sure to use nofail in the fstab so it’ll boot without the disk.

I also wrote a script that uses pct list and pct exec to run a command in each container to print out their IP address. It’s kinda hard to find all your guest images in Proxmox’ UI if you’re using DHCP to assign addresses. (I wonder if there’s a way to get Proxmox to manage DHCP for its guests. Part of me wants a separate subnet for all the Proxmox hosted stuff.)

Ubuntu VM: old server clone (240GB, only 30GB used.)

My old server is virtualized now, see this blog post. I plan to migrate everything out of here and shut it down eventually but it’s real nice to not have to do that all at once.

Hacking container: Ubuntu template (1.4GB)

I have one container that’s just for general hacking projects. I suspect I’ll rebuild this from time to time other than preserving my home directory. I used the Proxmox Ubuntu template to make it, making sure to turn DHCP on. It’s unprivileged (which breaks ping). Here’s some stuff I did after install:

  • locale-gen en_US.UTF-8
  • apt install joe avahi-daemon git zip unzip rsync openssl webp ripgrep pigz python3 python-is-python3 python3-venv python3-dev pkg-config build-essential sqlite3 keychain curl
  • tailscale: have to enable tun access in Proxmox to make this work
  • My usual home directory environment.

Plex container: tteck (4.6GB)

I installed the Plex media server using tteck’s Proxmox helper scripts. These are a set of shell scripts to install a container in an OS and then the apps. Not sure why they don’t just distribute a template instead. I chose Ubuntu 22.04 instead of Debian and then it installed whatever Plex itself needs.

My media files are on the USB drive I mounted on the host OS. I used a bindmount to make the directory available in the container. Note that bindmounts break Proxmox’ snapshot mechanism, but backups still work.

The resulting image works great. Intel QuickSync, the GPU accelerator for transcoding, just worked with no effort on my end. Plex itself is easy to set up. I configured Plex to not run scans, intro detection, etc every night so it wouldn’t use all that CPU and disk I/O. But those jobs work fine.

4.6GB seems huge. over half of that is in Plex cache directories that were generated after it started running. I only gave this container 8GB, I wonder if it’ll run itself out.

Unifi container: tteck (2.1GB)

The Ubiquiti device management controller. Another tteck script, with Debian 12 this time. Also installed Tailscale myself. Ubiquiti’s system requires you migrate devices from an old controller to a new one which is fairly simple, basically making a backup of the config and copying it over. The actual migration process is a little scary, if it goes badly you might have to hard reset your devices.

Samba container: Alpine template (0.07GB)

A network fileserver for my music files, for Sonos. I did this one fully manually, starting with the Alpine 3.18 template. it was really easy, basically just apk add smb. I had to bindmount the media drive just like Plex. I wrote a new config file from scratch, smb.conf gets a lot more readable if you remove the hundreds of lines of comments from it. Dimly remembered the special downgrades Sonos requires to work (unix extensions = no).

Docker VM: manually (32GB not all used)

I set up a Debian VM to run Docker and Portainer using these instructions. I wanted to see how Portainer worked but I don’t know that I’ll keep using it. It’s not even running right now.

Monitoring container: TBD

The main thing left in my old server’s VM is a bunch of custom scripts I wrote to log monitoring data. I set this up a couple of year ago with Telegraf + InfluxDB + Grafana and it works well. So well I keep adding monitoring hacks without being careful about it, so now it’s a bit of a hairball.

I think the migration path is to set up Debian or Ubuntu on a new container, then install Telegraf + InfluxDB + Grafana there. Then somehow migrate all my Influx data and Grafana configs over. And all my monitoring scripts in Telegraf. That’ll let me turn off the VM versions of those things without much data loss.

But I’m sorely tempted to also improve things as I move them. Productize the monitoring scripts a bit so next time I move them it’s simpler. And maybe move off of Influx to TimescaleDB (a Postgres extension). That’d be more fun and having the VM working gives me time to do that.

I’m also unclear whether I should set up a separate container for each monitoring process, plus an extra for influx + grafana, and write the data with a network socket. That’s maximal containerization but seems like overkill, I probably won’t bother.

Backups and snapshots

One annoyance: there’s no tool for backing up the Proxmox server itself. Most people say “eh, just reinstall” but it’d sure be nice to have a copy of the configuration. Some folks have hacked things by copying off the config files with a script.

Proxmox does have backup tools for VMs and containers which are basically filesystem copies. I’m not certain how hard they are to restore but the web GUI has a “restore” button so presumably push-button. There’s a nice set of backup options trading off consistency vs disruption. If you stop the guest entirely you can make a cleaner backup but you don’t have to. Backups can be run manually or scheduled.

Proxmox also has “snapshots” which not only capture disk state but also memory. This seems to work great with a VM; I could snapshot, rollback, and my running processes are back in the old state. There’s also snapshots for containers but they don’t work as well. Bindmounts disable them entirely. And the restore of a container is not confidence inspiring; it took 30+ seconds and only restored file state, not memory or running processes. That all makes sense given what a container is, but makes me wonder whether container snapshots are useful.

Note that a backup run in “snapshot” mode is a different thing from a “snapshot”.

Securing your Plex data

The Plex video player launched a new social media feature where it shows you things like “your friend Nelson watched Totally Licensed Movie last night”. You can see your feed of friends’ activity at this link. This seems to be part of a broad new product effort called Discover Together.

I didn’t opt into this sharing. I don’t want my friends to see a list of the TV shows I watch. Plex unilaterally decided to start collecting and publishing that data without my explicit consent. Which video files I watch is private data and potentially a legal problem. I can see how it’d be useful for Plex to become more of a social media app. But the abusive way they launched it makes me want to go scorched earth and block every aspect of data sharing I can from Plex.

Update: in a discussion on Mastodon a Plex engineer responded with a personal (not official) comment and said

You should have been shown two screens at some point; one to opt-in or out of view state syncing, and another more recently to opt in or out of the social sharing stuff, and would have needed to opt-in to both for any of this to be shared with friends.

So it’s possible I clicked something at some point to allow this.

Update 2: over on Reddit someone posted what the UI looks like for the opt-in I might have clicked. There’s four screens that pop up interrupting whatever you turned your TV on to watch. The first three are marketing copy, the fourth is the consent request. It’s very unlikely I paid enough attention to this to make an informed choice. It also looks like the default was to opt people in to friends sharing.

Update 3: PC Gamer has an article about Plex’ explanation of how people got this turned on without their consent. Turns out the “You’re in control” UI has a flow which turns off the privacy without the user intending it. Terrible design although not clear if it’s malice or incompetence.

Here’s what I did to preserve my privacy. I found two major things to block in Plex: watch history and ad preferences. There’s also some other minor account settings. Details below.

Profile settings: activity sharing

You can opt out of sharing what you are watching with friends by going to this link to edit your profile and selecting “Privacy Settings” at the bottom. “My Watch History” is the one I found most invasive.

Account setting: ads and more

Plex has a bunch of other privacy settings in your account. You can edit them by going to this link to edit your account and looking at the bottom for Privacy. There are several links there.

The most useful one is the Ad Vendors page, where you can opt out of them selling your data to 100+ marketing companies. This only works in some US states (thank you, California!) You have to disable your ad blocker to see the UI that lets you change things.

Here’s the list of opt-out states. The obvious typos are perhaps an indicator of how seriously Plex takes this part of their product.
California Colorado Connecticut Virginia Utah Indiana Iowa Montana Oregon Tennessee Texas Massachusettes New Jersey Pennsylvania Deleware

There’s also a “Privacy Preferences” link that takes you to this part of the webapp. It looks mostly like legalese text but if you look closely there is a checkbox you can turn off for “Send playback data to Plex”.

Further up the account settings page there’s also “Sync Your Watch State and Ratings”. That’s also keeping a record of what you watch. I think this particular feature is private to you and it provides a useful function, so I’ve left this one on for now.

Dark patterns

Plex’s scattered privacy settings seem designed to make it hard for users to find and configure them. It’s so hard to even find these things that I had to write a whole blog post. And after spending 30+ minutes on this I’m still not sure I got it all configured the way I want.

The playback preferences are buried deep in thousands of words of legalese text. The ad vendor preferences are only available to users from certain jurisdictions. And then the UI doesn’t even work if you are running an ad blocker (as likely 98% of people who get to this page are).

Maybe that’s all just bad design, Plex is not the most professional product. But it sure feels intentional, to keep users trapped in choices that benefit the company.

Unlocking AppleTV notes

I’m trying to unlock a new AppleTV 2 so I can use XBMC or Plex to play videos from my home network on my PC. It’s been seven years since I first ran XBMC on a hacked Xbox and it’s still way too hard to get low power hardware to play your own TV.

AwkwardTV seems like a useful reference.

Some notes on the jailbreak process:

  • Apple firmware is signed via some online process. You need a “shsh” signature to bless firmware to run, even on already jailbroken systems. In general Apple only signs the most recent firmware, so it’s very hard to downgrade firmware.
  • There’s a program called TinyUmbrella that will generate shsh for firmware you have already. However, it’s mostly not useful except generating a shsh for a current version. My AppleTV out of the box had 4.3 but I was “too late” to get a shsh for it, despite it running. TinyUmbrella is evil software that modifies /etc/hosts and does god knows what else as root. There’s a competitor called iFaith, which may get shsh even for old firmwares, but it’s Windows only.
  • Seas0npass is the preferred jailbreaking software. Their guide is quite good. Don’t be fooled that it’s dated a year ago; they keep updating the jailbreak software.
  • Jailbreaking really boils down to putting the AppleTV in DFU mode and reflashing the firmware with some funky thing. All the weirdness around Seas0npass is creating that firmware and then scripting iTunes to install it.
  • If something goes wrong this Seas0npass troubleshooting guide is great. In particular I had the problem of iTunes saying “This device isn’t eligible for the requested build”. Turns out TinyUmbrella had evilly rewritten my /etc/hosts and was breaking the iTunes update process; telling TinyUmbrella not to do that fixed it.
  • It took about seven tries, but I now have an Apple TV 2 running 4.4.4 (3330), but jailbroken. Ie: I can run my own software and the hardware I purchased.

Now what? Well simple thing is log in as root with the default password “alpine”. Hey, look, it’s like a Unix box! It’s even got apt-get, plus a bunch of apt sources of dodgy software.

First thing up is to install Plex, a media player that works by streaming video from a transcoding server. There are many sets of conflicting instructions on how to install Plex. This forum thread seems up to date as of January 2012. Conceptually...

  • Install Python via apt
  • Download this scary installer(a zip file)
  • Change your root password back to the default “alpine”
  • Run the scary installer
  • It reboots the Apple TV, and now you have Plex!
  • Run Plex, go to Settings / Security and disable tracking.
Plex Media Server is awfully finicky about finding files. It desperately wants to match video filenames to a poorly documented naming system; if files don’t match, they just don’t show up. And it tries to cache the scan so simply renaming files doesn’t really force a rescan. There’s no “scan everything” option in the web UI (there is in the native client). Oh, and the Web UI is terribly buggy and you have to reload it every time you change the folder list.

Next thing would be to install XBMC, but I’m already feeling bruised from dealing with all this poorly packaged hackerware. Full props to the folks making media software on unauthorized devices, but man is usability a challenge.

BTW, two crappy things about the Apple TV:

  • There’s no HDMI cable in the box
  • The remote is IR only