0

I'm new to the Pi, and have come across heaps of streams that seem to need you to pair using the same IP before they will play - Openload etc...

I read and found you can create a socks proxy that will let you route the traffic from your computer through the Pi, and hence have the same IP - making it simpler to pair and then play the stream.

This seems to work well: ssh -o ServerAliveInterval=60 -D 0.0.0.0:8888 10.0.1.100 and once this is done, I can set the Socks proxy of the PC/Mac to 10.0.1.100:1080.

My question is how oh how can I get this command to run automatically when the Pi starts up? I'm running OSMC, and have tried just about everything I can think of to get it to run; the closest I seem to have got is creating a script with this in, then setting the script to run in /etc/rc.local. If I just run it like this, it always gives permission denied - presumably because it is trying to run it as root...

When I run it as my logged on user (osmc) it runs fine, but I'll be stuffed if I can figure out how to get it to run automatically at startup. If any one is able to help me get this going, I'd be incredibly grateful - I've been trawling the web trying everything I can see for about four hours :-)

0

Starting services at boot we use systemd. Try this:

rpi ~$ sudo systemctl edit --force --full socksproxy.service

Insert this statements, save them and quit the editor:

[Unit]
Description=My Socks Proxy
Wants=network-online.target
After=network-online.target

[Service]
User=osmc
WorkingDirectory=/home/osmc
ExecStart=/usr/bin/ssh -o ServerAliveInterval=60 -nNT -D 0.0.0.0:8888 10.0.1.100

[Install]
WantedBy=graphical.target

Enable, start and check the service:

rpi ~$ sudo systemctl enable socksproxy.service
rpi ~$ sudo systemctl start socksproxy.service
rpi ~$ systemctl status socksproxy.service
rpi ~$ journalctl --unit=socksproxy --pager-end

You can modify the service, no need to reboot:

rpi ~$ sudo systemctl edit --full socksproxy.service
rpi ~$ sudo systemctl daemon-reload
rpi ~$ sudo systemctl restart socksproxy.service

Check status and journalctl as shown above. You can show a Unit source with:

rpi ~$ systemctl cat socksproxy.service
  • Thanks so much for your reply! I setup the file and ran the commands as you said; is it normal that on the first command (adding the statements) the file was empty, and had a heap of numbers appended to the end - see screenshots: [link] (imgur.com/a/H0MulnW)? Then the enable & start commands ran without issue, but see the results in the link for the last two - both had to be exited with Ctrl+C, I couldn't issue any further commands, and it doesn't seem to have worked. Thanks again for your help! – dmr May 21 '18 at 20:26
  • @dmr Output looks as expected. That is the logging to see what's going wrong. If it runs the right way the output would be reduced. It is shown in the pager less. Better to quit with q instead of Ctrl-C. Type h and you will see help. The service runs without error. (code=exited), Status=0/SUCCESS) shows me, but the service should not exit. ssh isn't running the right way (the thing with Pseudo-terminal). I will have a look at it. – Ingo May 21 '18 at 21:00
  • @dmr I have updated my answer and added the options -nNT to ssh. Try that. I have also added how to modify a Unit. – Ingo May 21 '18 at 22:40
  • THANK YOU SO MUCH for the help, Genius - it worked a treat!! Hopefully this helps some others as well :-) – dmr May 22 '18 at 9:20

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.