Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I connect to a remote ssh server by running this command:

ssh -D 12345 bob@myserver.com

This creates a socks proxy that I can use with Firefox to bypass censorship in my country. However, I can't take advantage of it to in the command line.

Let's say my country blocks access to youtube. How can I use the ssh connection to run a command such as:

youtube-dl youtube.com/watch?V=3XjwiV-6_CA

Without being blocked by the government? How I can set a socks proxy for all terminal commands?

share|improve this question
    
I found a temporary solution. I've used tsocks. Once installed, when the ssh connection is established, I launch the application I want with tsocks as follows: tsocks gnome-terminal –  user1098135 Apr 9 '13 at 4:08

3 Answers 3

up vote 2 down vote accepted

Youtube-dl doesn't support a SOCKS proxy. There's a feature request for it, with links to a couple of working proposals.

Youtube-dl supports HTTP proxies out of the box. To benefit from this support, you'll need to run a proxy on myserver.com. Pretty much any lightweight proxy will do, for example tinyproxy. The proxy only needs to listen to local connections (Listen 127.0.0.1 in tinyproxy.conf). If the HTTP proxy is listening on port 8035 (Port 8035), run the following ssh command:

ssh -L 8035:localhost:8035 bob@myserver.com

and set the environment variables http_proxy and https_proxy:

export http_proxy=http://localhost:8035/ https_proxy=http://localhost:8035/
youtube-dl youtube.com/watch?V=3XjwiV-6_CA
share|improve this answer
    
if they are going to use SSH then why do they need tinyproxy or vice versa? I use SSH tunnel and it works fine. –  Neutralizer Sep 14 at 9:54
    
@Neutralizer SSH only relays from the local machine to the proxy machine. Something on the proxy machine needs to decode the HTTP request and figure out the IP address of the server machine. If the client supports SOCKS then SSH can do the job, but youtube-dl doesn't support SOCKS. If you're using the proxy for a specific server, you may be able to use SSH alone and tell it to forward directly to that server, but that only works if all the requests need to be forwarded to the same IP address and port. –  Gilles Sep 14 at 12:06

If Youtube videos are what you are after, you might want to try cclive, which seems to support proxies. And it can do other streaming sites as well.

share|improve this answer
ssh -D 8080 name@myserver.com

export http_proxy=socks5://127.0.0.1:8080 https_proxy=socks5://127.0.0.1:8080

youtube-dl youtube.com/watch?V=3XjwiV-6_CA
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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