13

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?

  • 3
    I'm just curious: How do you watch a video trough ssh? – Radu Rădeanu Nov 5 '13 at 19:19
  • 4
    @RaduRădeanu he's forwarding the Xserver ;) – Braiam Nov 5 '13 at 19:24
  • I was saying about youtube video. after connecting I just open a browser and watch youtube there. It works but gives several error messages about pulse audio. I have tried vlc to open .mp4 and .avi files. vlc stops working saying "Audio output failed: The audio device "default" could not be used: Connection refused." – souravc Nov 5 '13 at 19:36
8

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 paprefs

Whenever you SSH with X11 forwarding enabled, PulseAudio programs use X11 to discover your sound server (use pax11publish or

xprop -root PULSE_SERVER

to see for yourself). Just tell PulseAudio to listen for network connections (paprefs as 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 X11 PULSE_COOKIE property, or you can copy ~/.pulse_cookie manually.)

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 pax11publish to discover your PulseAudio port (usually 4713), connect with

ssh -R > 24713:localhost:4713`

then run

export PULSE_SERVER="tcp:localhost:24713"

This will be slightly slower due to SSH overhead, but is safe to use over the Internet.

  • From @Fusca Software: Just a comment to the last answer: First redirecting a Browser with youtube will hardly work over a 1GBit-Connection, so I think I will not use it over a public (Internet) connection. Second, if you watch a youtube (!!!) video, I don't think you should secure the audio stream :D – George Mathioudakis Sep 17 '17 at 13:04

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.