Browser Audio over SSH with X-Forwarding?

More of a tech question than technical support. But do any of you know how to get audio while using a browser over SSH on a remote server? I’m sure it’s doable, but all the websites I’ve been finding are 10 to 12 years old with outdated advice. Right now, I can open Google Chrome remotely, over SSH, but without sound. Thanks!

Interestingly, I’m just after a similar issue. I want to let my wife watch DVB-S TV on her machine. The TV card is set in my desktop, kaffeine is running well via SSH -X, yet without sound.

I have found this thread:
paprefs is available, but I didn’t have the time to test this, yet. I have to install it on the host, but that’s not running, now.

I saw that, but that thread is over 9 years old and when I experimentally tried to install paprefs, zypper complained about dependencies and wanted to uninstall some pulseaudio dependencies (if I remember correctly). If you try it, mark in snapper so you can roll back if strange things happen.

In the meantime, this passage came from a very recent Reddit thread (didn’t save the link):

PulseAudio is now slowly being replaced by PipeWire. Pretty sure it has a reimplementation of this feature, but I haven’t tried it. And I can’t give you a full list, but I know Fedora and Arch (at least with GNOME) already made the switch

e: just tried it out with PipeWire on both machines (0.3.45 and 0.3.44), it works. In my testing it stutters a bit, but that may be because I’m sending it over the network and then over Bluetooth to my headphones. See here or here’s a quick summary of how I got it to work:

On the device where you want to hear the audio:

pactl load-module module-native-protocol-tcp listen=
pactl load-module module-zeroconf-publish

And on the device(s) where you want to play it:

pactl load-module module-zeroconf-discover

After a bit you should see all inputs/outputs as "(name) on (username)@(hostname)

Also found similar advice here:

On linux:

Machine where you want to listen music:

pactl load-module module-native-protocol-tcp

On remote machine that producing music:

pactl load-module module-tunnel-sink server=IP-addrd-of-listener

Just forward local port over ssh to remote machine that will pipe music to you back.

I haven’t had time to try these but these seem to be the most recent methods I could find. There’s lots of outdated stuff floating around out there, but maybe the old methods would still work?

I have to admit I’m not familiar with pipewire although it was apparently installed with some distro upgrade. And I keep being confused by all the sound server versions and options. So, sticking with the old stuff (still running fine) for a while I tried paprefs. It installed and ran without any complaint but no luck, yet. I got “connection refused by sound server” after starting kaffeine. After checking the more detailed, original explanation here
I think I might not have properly restarted pulseaudio. Well, priority is not high. Wife is upstairs watching a girls film on DVD, no tinkering with any audio up there without risk of life. :shushing_face:
So, I’m sitting downstairs watching TopGear Season 15. :sunglasses:
I might “stalk” her via ssh later on, though. :thinking:

Edit came too late: There’s no joke-button. By “stalking” of course I don’t mean spying. But when I’m up for some thrill, I might send her a kdialog to the screen saying “hello”. I might have to sleep down here then, however. :laughing:

I became curious and if Chrome is using PulseAudio it actually is pretty trivial. The Streaming Audio on your LAN shows how to add additional sink and then use any of the usual PA configuration frontends to direct output to this sink, like

paplay -p -d MyOSMC /usr/share/sounds/freedesktop/stereo/bell.oga

Or one could just specify server directly

PULSE_SERVER= paplay -p  /usr/share/sounds/freedesktop/stereo/bell.oga

Of course it works just fine with ssh tunneling as well.

client$ ssh -R 4713:localhost:4713 ...
server$ PULSE_SERVER=localhost:4713 paplay -p  /usr/share/sounds/freedesktop/stereo/bell.oga

I was just going to try the pactl solution until I saw arvidjaar’s post below. Both of your comments made me laugh. :slight_smile: Thanks. Just out of curiosity, and because it’s been in the news, I asked ChatGPT, but go tall kinds of outdated advice. So much for the promise of AI. For now.

Whoa. Okay. This is all definitely above my pay grade. I mean, I can mindlessly copy & paste what you’re doing here, but I’m going to see if I can drill down and understand what’s going on. If you’re willing, and can clarify some of what these commands are doing, feel free. I’ll visit man pages and google in the meantime. Thank you!

You just need to tunnel TCP connection for PulseAudio like you tunnel X11 connection.

client$ pactl load-module module-native-protocol-tcp listen= auth-anonymous=true

Loads PulseAudio TCP support in the currectly running PA server. Module listens for connection on loopback address and does not require any authentication.

client$ ssh -o userknownhostsfile=/dev/null -o StrictHostKeyChecking=no localhost -p 2222 -R 4713:localhost:4713

Connects to running VM, the only relevant parameter is -R which sets up forwarding from connections to port 4713 in VM to local port 4713 on client.

VM$ PULSE_SERVER=localhost:4713 chromium

Starts Chromium on VM telling its PulseAudio component to connect to port 4713 on VM which gets forwarded to port 4713 on ssh client. Youtube audio works :slight_smile:
paplay was used simply to quickly test whether audio forwarding works.

This assumes that your client (from which you ssh) actually runs PulseAudio server. If it is using pipewire - I do not know.

Thank you! This is a huge help.

Most welcome! :slight_smile: Probably that’s how I’m trying to compensate my lack of knowledge. :upside_down_face:
Now I should focus on the actual issue. I can confirm that the “old stuff” still works, as explained in the superuser-dot-com thread. I was too focused on my own kaffeine issue. Today, after rebooting my desktop - wife close by in mild mood - I ssh-ed into it from my laptop. Just to make sure, I (again) entered pax11publish and xprop -root PULSE_SERVER. I really don’t know if that was necessary, however. I started Chrome, sound works, probably not the best quality.
Then I have had a second thought on my kaffeine issue. After all, pulseaudio is running on user level and kaffeine is an X program. It turned out, kaffeine was expecting my user to be logged in not just via ssh but running an actual X session on the host, my desktop. I keep avoiding loging into both machines as I’m syncing my profiles to the server and unison doesn’t like changes on both sides. Minor issue I could overcome. Now, it’s just working. I’m sitting downstairs, again, watching on my laptop from upstairs’ desktop the end of the movie I have running down here on my TV with timeshift.
Why am I doing it? Mostly, because (or rather to see if) I can. My wife will probably never use it as it is too much hassle to login via ssh …
Unfortunately, it wasn’t even any help for you as you couldn’t install paprefs and arvidjaar’s solution is more sophisticated having the audio stream encrypted via ssh. It was fun trying, anyway. :grinning: