<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kusnaware</title>
    <description>The latest articles on DEV Community by Kusnaware (@kusnaware).</description>
    <link>https://dev.to/kusnaware</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3884669%2F46b5bb66-f67e-4c9e-addd-8ad83370433a.JPG</url>
      <title>DEV Community: Kusnaware</title>
      <link>https://dev.to/kusnaware</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kusnaware"/>
    <language>en</language>
    <item>
      <title>I touched X11 for the first time in 30 years to run wrangler login. YouTube audio came with it.</title>
      <dc:creator>Kusnaware</dc:creator>
      <pubDate>Mon, 20 Apr 2026 15:49:51 +0000</pubDate>
      <link>https://dev.to/kusnaware/i-touched-x11-for-the-first-time-in-30-years-to-run-wrangler-login-youtube-audio-came-with-it-1928</link>
      <guid>https://dev.to/kusnaware/i-touched-x11-for-the-first-time-in-30-years-to-run-wrangler-login-youtube-audio-came-with-it-1928</guid>
      <description>&lt;h2&gt;
  
  
  What this post is about
&lt;/h2&gt;

&lt;p&gt;Here’s what I actually ended up doing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I wanted to run &lt;code&gt;wrangler login&lt;/code&gt; on a GUI-less Ubuntu Server for a Cloudflare Workers project&lt;/li&gt;
&lt;li&gt;I already knew that &lt;strong&gt;API Token is the proper solution&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;But I still wanted to see whether X11 forwarding could push the browser window to macOS&lt;/li&gt;
&lt;li&gt;It worked&lt;/li&gt;
&lt;li&gt;Then I got carried away, added PulseAudio forwarding, and ended up playing both YouTube video and audio on the macOS side&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;macOS host&lt;/li&gt;
&lt;li&gt;VMware Fusion&lt;/li&gt;
&lt;li&gt;Ubuntu Server 24.04 guest&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Why I even touched X11 in 2026
&lt;/h2&gt;

&lt;p&gt;I was working on a Cloudflare Workers project and needed to run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wrangler login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That launches a browser for OAuth authentication.&lt;/p&gt;

&lt;p&gt;The problem was simple: my working environment was &lt;strong&gt;Ubuntu Server&lt;/strong&gt;, not Ubuntu Desktop. No GUI, no local browser, no OAuth screen.&lt;/p&gt;

&lt;p&gt;At that point there were two obvious options:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API Token&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;The proper way. Generate a token in Cloudflare Dashboard and export it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;X11 forwarding&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Push the Ubuntu-side browser window to macOS&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I knew from the beginning that API Token was the sane answer.&lt;/p&gt;

&lt;p&gt;I used X11 anyway.&lt;/p&gt;

&lt;p&gt;Partly because I wanted to know whether it still worked. Partly because it had been about 30 years since I last touched X11, and apparently I make bad decisions in historically accurate ways.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 1: Basic X11 forwarding setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  On macOS: install XQuartz
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--cask&lt;/span&gt; xquartz
open &lt;span class="nt"&gt;-a&lt;/span&gt; XQuartz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  On Ubuntu Server: install required packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; xauth x11-apps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Enable X11 forwarding in sshd
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;vi /etc/ssh/sshd_config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Uncomment or set:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="n"&gt;X11Forwarding&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;
&lt;span class="n"&gt;X11DisplayOffset&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then restart SSH:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart sshd
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;X11DisplayOffset&lt;/code&gt; tells &lt;code&gt;sshd&lt;/code&gt; which display number to start using for forwarded X11 sessions. The default is &lt;code&gt;10&lt;/code&gt;. In practice, &lt;code&gt;$DISPLAY&lt;/code&gt; often ends up around &lt;code&gt;localhost:10.0&lt;/code&gt;, unless that display number is already occupied.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Test it
&lt;/h3&gt;

&lt;p&gt;From macOS, connect from XQuartz's &lt;code&gt;xterm&lt;/code&gt; first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-Y&lt;/span&gt; user@ubuntu-vm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then on Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$DISPLAY&lt;/span&gt;
xclock &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a clock window appears on your Mac, X11 forwarding is working.&lt;/p&gt;




&lt;h2&gt;
  
  
  One thing that tripped me up
&lt;/h2&gt;

&lt;p&gt;In &lt;strong&gt;my&lt;/strong&gt; environment, an already-open Terminal.app session did not reliably get a usable &lt;code&gt;$DISPLAY&lt;/code&gt;, while XQuartz's &lt;code&gt;xterm&lt;/code&gt; worked consistently.&lt;/p&gt;

&lt;p&gt;That does &lt;strong&gt;not&lt;/strong&gt; mean Terminal.app is fundamentally incompatible.&lt;/p&gt;

&lt;p&gt;Possible causes include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;XQuartz was installed but I had not fully logged out and back in yet&lt;/li&gt;
&lt;li&gt;shell startup files like &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt; were overwriting &lt;code&gt;$DISPLAY&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So if X11 forwarding behaves strangely, trying XQuartz's own &lt;code&gt;xterm&lt;/code&gt; is a fast sanity check.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Firefox trap — Snap strikes again
&lt;/h2&gt;

&lt;p&gt;My first attempt was the obvious one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;firefox &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That failed with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X11 connection rejected because of wrong authentication.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why?
&lt;/h3&gt;

&lt;p&gt;On Ubuntu 22.04 and later, Firefox is usually delivered via &lt;strong&gt;Snap&lt;/strong&gt;. Snap isolation and X11 forwarding do not get along particularly well in this setup.&lt;/p&gt;

&lt;p&gt;You can confirm it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;which firefox
&lt;span class="c"&gt;# /snap/bin/firefox&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I switched to a non-Snap build.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 3: Install &lt;code&gt;firefox-esr&lt;/code&gt; with APT pinning
&lt;/h2&gt;

&lt;p&gt;I used the &lt;code&gt;mozillateam&lt;/code&gt; PPA and installed &lt;code&gt;firefox-esr&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Important detail: if you do this carelessly, later &lt;code&gt;apt install&lt;/code&gt; / &lt;code&gt;apt upgrade&lt;/code&gt; operations may drag you back toward Ubuntu's Firefox transition package and the Snap path.&lt;/p&gt;

&lt;p&gt;So I pinned it explicitly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;add-apt-repository &lt;span class="nt"&gt;-y&lt;/span&gt; ppa:mozillateam/ppa

&lt;span class="nb"&gt;sudo tee&lt;/span&gt; /etc/apt/preferences.d/mozilla-firefox &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;'
Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001

Package: firefox*
Pin: release o=Ubuntu
Pin-Priority: -1
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; firefox-esr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A couple of notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;this &lt;code&gt;mozillateam&lt;/code&gt; PPA is &lt;strong&gt;not&lt;/strong&gt; the same thing as Mozilla's own &lt;code&gt;packages.mozilla.org&lt;/code&gt; APT repository&lt;/li&gt;
&lt;li&gt;I used it here because it solved the practical problem at hand&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Pin-Priority: 1001&lt;/code&gt; strongly prefers that source&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Pin-Priority: -1&lt;/code&gt; blocks Ubuntu's matching package candidates&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;firefox-esr &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this time the browser window actually appeared on macOS.&lt;/p&gt;

&lt;p&gt;I also got these warnings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No matching fbConfigs or visuals found
glx: failed to create drisw screen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They looked dramatic, but in practice they just meant GPU acceleration was not happening. The browser still worked.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 4: &lt;code&gt;wrangler login&lt;/code&gt; finally works
&lt;/h2&gt;

&lt;p&gt;Now the original goal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wrangler login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Firefox ESR opened, Cloudflare's authentication page appeared, and login completed successfully.&lt;/p&gt;

&lt;p&gt;At that point the real task was done.&lt;/p&gt;

&lt;p&gt;Which should have been the end.&lt;/p&gt;

&lt;p&gt;Instead, my brain immediately asked a much worse question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If Firefox is already showing up on macOS, can I make YouTube audio come through too?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is how projects rot.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 5: Why video worked but audio did not
&lt;/h2&gt;

&lt;p&gt;At this point YouTube video rendered fine over X11.&lt;/p&gt;

&lt;p&gt;Audio did not.&lt;/p&gt;

&lt;p&gt;That is expected, because X11 was never designed to forward audio.&lt;/p&gt;

&lt;h3&gt;
  
  
  X11 forwards:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;window drawing commands&lt;/li&gt;
&lt;li&gt;keyboard input&lt;/li&gt;
&lt;li&gt;mouse input&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  X11 does &lt;strong&gt;not&lt;/strong&gt; forward:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;audio&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So if I wanted audio too, I needed a second path.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 6: PulseAudio forwarding
&lt;/h2&gt;

&lt;p&gt;The idea was:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;run a PulseAudio server on macOS&lt;/li&gt;
&lt;li&gt;expose it to Ubuntu through SSH reverse port forwarding&lt;/li&gt;
&lt;li&gt;tell Firefox on Ubuntu to use that forwarded PulseAudio endpoint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5zx7al3634ue8ragwaa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj5zx7al3634ue8ragwaa.png" alt="Audio flow diagram: firefox-esr on Ubuntu sends audio to a local PulseAudio client, which forwards it over an SSH reverse tunnel to the PulseAudio server on macOS, then to the speakers" width="800" height="54"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  On macOS: install and run PulseAudio
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;pulseaudio
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/.config/pulse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run it in the foreground:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pulseaudio &lt;span class="nt"&gt;--load&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"module-native-protocol-tcp auth-anonymous=1 auth-ip-acl=127.0.0.1"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
           &lt;span class="nt"&gt;--exit-idle-time&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;-1&lt;/span&gt; &lt;span class="nt"&gt;--daemonize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;no
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may see warnings like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;W: [] caps.c: Normally all extra capabilities would be dropped now...
W: [] socket-util.c: IP_TOS failed: Invalid argument
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In my case they did not break anything.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;auth-anonymous=1&lt;/code&gt; is only acceptable here because this was a temporary setup behind SSH tunneling and limited to localhost. Exposing it more broadly would be reckless.&lt;br&gt;&lt;br&gt;
Yes, this is sketchy. No, I would not do this on a real server.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also worth noting: PulseAudio is still usable here, but its own maintainers have said development has slowed down considerably, with bigger new work moving toward PipeWire / WirePlumber. For this kind of hack, it is still convenient.&lt;/p&gt;

&lt;h3&gt;
  
  
  On Ubuntu Server: install audio-related packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; ubuntu-restricted-extras ffmpeg libavcodec-extra pulseaudio
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;This post assumes &lt;strong&gt;Ubuntu Server 24.04&lt;/strong&gt;. On Ubuntu Desktop 24.04, PipeWire / &lt;code&gt;pipewire-pulse&lt;/code&gt; is the more standard baseline, so blindly adding PulseAudio can make the setup messier.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Phase 7: SSH with both X11 and audio forwarding
&lt;/h2&gt;

&lt;p&gt;From macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-Y&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 24713:localhost:4713 user@ubuntu-vm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meaning:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Y&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Trusted X11 forwarding&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-R 24713:localhost:4713&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Reverse forward Ubuntu port &lt;code&gt;24713&lt;/code&gt; to macOS PulseAudio port &lt;code&gt;4713&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;24713&lt;/code&gt; port number was not magical. I just took PulseAudio's default &lt;code&gt;4713&lt;/code&gt; and added &lt;code&gt;20000&lt;/code&gt; so it would be easy to recognize and unlikely to collide.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why &lt;code&gt;-Y&lt;/code&gt; and not &lt;code&gt;-X&lt;/code&gt;?
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-X&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Untrusted X11 forwarding. Safer, but some apps break&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Y&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Trusted X11 forwarding. Less restricted, more dangerous&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This part matters:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Only use &lt;code&gt;-Y&lt;/code&gt; with machines you fully control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A trusted X11 client can do nasty things, including keystroke monitoring. On your own VM behind your own SSH connection, fine. On someone else's server, absolutely not.&lt;/p&gt;




&lt;h2&gt;
  
  
  Phase 8: Point Ubuntu at the forwarded PulseAudio server
&lt;/h2&gt;

&lt;p&gt;On Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PULSE_SERVER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;tcp:localhost:24713
firefox-esr &amp;amp;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At that point, both YouTube &lt;strong&gt;video and audio&lt;/strong&gt; came through on the macOS side.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9rbyrquwl5aa906hzyi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz9rbyrquwl5aa906hzyi.png" alt="Architecture diagram showing the Ubuntu Server guest VM running firefox-esr on the left, connected to the macOS host on the right through an SSH tunnel that carries both X11 forwarding for the display and a reverse port forward for PulseAudio audio" width="800" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Against all dignity, it worked.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why video and audio stayed in sync
&lt;/h2&gt;

&lt;p&gt;A fair question here is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;X11 and PulseAudio are two different protocols on two different forwarding paths. Why didn't the audio drift badly?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The answer is that &lt;strong&gt;Firefox handled synchronization&lt;/strong&gt;, not X11 or PulseAudio.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the media stream contains timestamps&lt;/li&gt;
&lt;li&gt;Firefox schedules video frames and audio chunks against those timestamps&lt;/li&gt;
&lt;li&gt;both streams are delayed by the tunnel, but roughly in similar ways&lt;/li&gt;
&lt;li&gt;so the playback remains acceptably synchronized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So no, there is no elegant protocol-level sync mechanism here.&lt;/p&gt;

&lt;p&gt;This is application-layer behavior carrying the whole mess on its back.&lt;/p&gt;




&lt;h2&gt;
  
  
  Security notes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;Notes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;X11 forwarding&lt;/td&gt;
&lt;td&gt;OK-ish&lt;/td&gt;
&lt;td&gt;Encrypted through SSH&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PulseAudio forwarding&lt;/td&gt;
&lt;td&gt;OK-ish&lt;/td&gt;
&lt;td&gt;Also inside SSH&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;auth-anonymous=1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Risky unless contained&lt;/td&gt;
&lt;td&gt;Keep it local and temporary&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;auth-ip-acl=127.0.0.1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Good idea&lt;/td&gt;
&lt;td&gt;Restricts access to localhost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;-Y&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Dangerous&lt;/td&gt;
&lt;td&gt;Use only with hosts you trust completely&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SSH auth&lt;/td&gt;
&lt;td&gt;Critical&lt;/td&gt;
&lt;td&gt;Use keys, not password login&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The weak point here is not X11 itself.&lt;/p&gt;

&lt;p&gt;It is you doing something sloppy with trust boundaries.&lt;/p&gt;

&lt;p&gt;As usual.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I took away from this
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. X11 is ancient, but still weirdly capable
&lt;/h3&gt;

&lt;p&gt;The design is old, backwards-seeming, and slightly cursed.&lt;/p&gt;

&lt;p&gt;And yet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the display server lives on the machine with the screen&lt;/li&gt;
&lt;li&gt;the application runs somewhere else&lt;/li&gt;
&lt;li&gt;the UI still shows up where you need it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That idea is ancient, but not dead.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Small UNIX-y pieces still compose in absurd ways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;SSH handled encryption and tunneling&lt;/li&gt;
&lt;li&gt;X11 handled remote windows&lt;/li&gt;
&lt;li&gt;PulseAudio handled audio transport&lt;/li&gt;
&lt;li&gt;Firefox glued the user experience together&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No single part was especially elegant.&lt;/p&gt;

&lt;p&gt;Together, they were good enough to get something undeniably stupid working.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The correct answer was still API Token
&lt;/h3&gt;

&lt;p&gt;Let me be very clear:&lt;/p&gt;

&lt;p&gt;If your real goal is just to use Cloudflare Workers cleanly on a headless machine, &lt;strong&gt;use API Token&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That remains the proper answer.&lt;/p&gt;

&lt;p&gt;This post is about the side quest.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final result
&lt;/h2&gt;

&lt;p&gt;I started out trying to solve a boring problem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;run &lt;code&gt;wrangler login&lt;/code&gt; on Ubuntu Server without a local GUI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I ended up with something much dumber and much more entertaining:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;X11-forwarded Firefox on macOS&lt;/li&gt;
&lt;li&gt;successful Cloudflare OAuth login&lt;/li&gt;
&lt;li&gt;PulseAudio tunneled over SSH&lt;/li&gt;
&lt;li&gt;YouTube video &lt;strong&gt;and&lt;/strong&gt; audio playing through the host machine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Was it necessary? No.&lt;/p&gt;

&lt;p&gt;Was it the right solution? Also no.&lt;/p&gt;

&lt;p&gt;Did it work?&lt;br&gt;&lt;br&gt;
Annoyingly, yes.&lt;/p&gt;

&lt;p&gt;Moral of the story: Sometimes the correct solution is boring. The fun solution is X11 + PulseAudio + questionable life choices.&lt;/p&gt;

</description>
      <category>x11</category>
      <category>pulseaudio</category>
      <category>ssh</category>
      <category>cloudflare</category>
    </item>
  </channel>
</rss>
