This guide shows you how to route sound from your Windows client to your remote Linux server using PulseAudio and SSH tunneling. This enables your CLI agent or remote application (like Hermes) to record and play sound directly.
-
Download PulseAudio for Windows:
- Download the latest community-maintained build (e.g.,
pulseaudio-win32by pgaskin). - Extract the files to a local directory (e.g.,
C:\pulseaudio).
- Download the latest community-maintained build (e.g.,
-
Configure PulseAudio (
C:\pulseaudio\etc\pulse\default.pa):- Open
default.pain a text editor. - Disable Unix domain sockets (they are not supported on Windows and cause crashes).
- Enable TCP loopback with anonymous authorization:
# Comment out or delete this line: # load-module module-native-protocol-unix # Add/Modify this line: load-module module-native-protocol-tcp auth-anonymous=1 listen=127.0.0.1
- Open
-
Configure the Daemon (
C:\pulseaudio\etc\pulse\daemon.conf):- Open
daemon.confand ensure PulseAudio does not exit when idle:exit-idle-time = -1
- Open
-
Launch PulseAudio:
- Open PowerShell and start the daemon:
& "C:\pulseaudio\bin\pulseaudio.exe" -n -F "C:\pulseaudio\etc\pulse\default.pa"
- To verify it is running and listening locally:
Get-NetTCPConnection -LocalPort 4713
- Open PowerShell and start the daemon:
To securely tunnel the sound data back to your local machine, establish an SSH connection with a remote reverse port forward. Run this on your Windows machine:
ssh -R 4713:127.0.0.1:4713 <user>@your-server-ipThis maps port 4713 on the server back to your Windows client's local PulseAudio server on 127.0.0.1. Keep this terminal window open to preserve the tunnel.
-
Install Dependencies:
apt-get update && apt-get install -y libasound2-plugins pulseaudio-utils -
Configure ALSA Routing (
~/.asoundrc):- Create or edit
~/.asoundrcon the remote server to route default audio through Pulse:pcm.!default { type pulse } ctl.!default { type pulse }
- Create or edit
-
Configure Environment Variables:
- Shell Session: Explicitly point applications to the forwarded TCP port on localhost:
export PULSE_SERVER=tcp:127.0.0.1:4713 - Shell Persistence: Add it to your shell startup script (
~/.bashrc):echo 'export PULSE_SERVER=tcp:127.0.0.1:4713' >> ~/.bashrc
- Tmux Session (If applicable): Update the tmux environment:
tmux set-environment PULSE_SERVER tcp:127.0.0.1:4713
- Shell Session: Explicitly point applications to the forwarded TCP port on localhost:
-
Configure for Services (Systemd / Hermes): If you run Hermes or other audio-dependent services under systemd, you must set the environment variable for the systemd manager:
- For User Services (
systemctl --user):systemctl --user set-environment PULSE_SERVER=tcp:127.0.0.1:4713 systemctl --user restart hermes-gateway
- For System Services (
systemctl):systemctl set-environment PULSE_SERVER=tcp:127.0.0.1:4713 systemctl restart hermes-gateway
- For User Services (
To verify that the server can communicate with your local Windows PulseAudio server over the tunnel, run:
export PULSE_SERVER=tcp:127.0.0.1:4713
pactl infoIf the connection is successful, it should return details about the PulseAudio server running on your Windows machine:
Server String: tcp:127.0.0.1:4713
Library Protocol Version: 35
Server Protocol Version: 35
Is Local: no
Host Name: DESKTOP-GK4FH6H
Server Name: pulseaudio
Server Version: 15.0-paw32-5
Default Sink: waveout
Default Source: wavein