Is there a way to carry audio over ssh?
Say after connecting to remote machine through ssh -X I opened a browser and want to watch a youtube video. Currently I could only able to watch the video without any audio. But I want to hear the audio too. How to do that?
1 Answer
How to carry audio over SSH?
Stolen answer from grawity in SuperUsers:
The easy way: Run
paprefs, go to Network Server and check Enable network access to local sound devices.
You need to install it using
sudo apt-get install paprefsWhenever you SSH with X11 forwarding enabled, PulseAudio programs use X11 to discover your sound server (use
pax11publishor
1xprop -root PULSE_SERVERto see for yourself). Just tell PulseAudio to listen for network connections (
paprefsas described above), and all X11 programs will be able to use it.(Other users will not have access to your sound server, unless you allow it yourself in
paprefs. The authentication data is carried over in the X11PULSE_COOKIEproperty, or you can copy~/.config/pulse/cookiemanually.)Note however, that the PulseAudio stream is not encrypted this way, so it is okay for use at home, but not over the Internet.
The slightly more complicated way: Enable network access as above, but tunnel PulseAudio over SSH TCP forwarding. Use
pax11publishto discover your PulseAudio port (usually 4713), connect withssh -R 24713:localhost:4713then run
export PULSE_SERVER="tcp:localhost:24713"This will be slightly slower due to SSH overhead, but is safe to use over the Internet.