Sharing Bluetooth audio output over SSH on Linux is not straightforward because SSH is primarily designed for terminal access and does not natively support audio streaming. However, you can achieve this by combining several tools and techniques. Here’s a step-by-step approach:
PulseAudio is the most common sound server on Linux and can be configured to stream audio over a network.
bashsudo apt install pulseaudio pulseaudio-utils
Add these lines:bashsudo nano /etc/pulse/default.pa
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;YOUR_LOCAL_IP load-module module-zeroconf-publish
bashpulseaudio -k && pulseaudio --start
bashssh -R 4713:localhost:4713 user@remote-machine
bashexport PULSE_SERVER=tcp:localhost:4713
parec and paplay for Direct StreamingIf you want to stream audio directly from the Bluetooth device:
Replacebashparec --device=BLUETOOTH_DEVICE_NAME --format=s16le --rate=44100 --channels=2 | ssh user@local-machine "paplay --format=s16le --rate=44100 --channels=2"
BLUETOOTH_DEVICE_NAME with the actual name of your Bluetooth audio device.ffmpeg and sshIf PulseAudio is not an option, you can use ffmpeg to capture and stream audio:
bashffmpeg -f pulse -i BLUETOOTH_DEVICE_NAME -acodec libmp3lame -f rtp rtp://local-machine-ip:1234
bashffplay -f rtp rtp://localhost:1234
If you need more control, set up a virtual audio cable (e.g., snd-aloop) on the remote machine and route Bluetooth audio through it, then stream the virtual device over SSH.