Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Raspberry Pi as SSH/VPN server and torrent box.

  • 27-01-2014 12:06am
    #1
    Registered Users, Registered Users 2 Posts: 1,792 ✭✭✭


    Hi guys, first post in this part of boards. Haven't a massive amount linux experience beyond a few installs of Mint or Ubuntu for clients and PartedMagic for troubleshooting or recovery. Something I'm starting to brush up on and hopefully pick up a few tricks.

    Picking up a raspberry Pi shortly and there are a couple of things I hope to do on it:

    1. Secure browsing while on an un-trusted or public network via SSH or VPN to my Pi on my home network. I can also get RTE player and geo locked content while abroad pretty easy which is a nice bonus.

    2. Use it as an always on torrent client. Access it remotely to with the likes of utorrent webui or their android remote app.

    - - - - - - - - - -

    Okay so I'm going to fire out a few questions.

    Firstly is it feasible to run both an SSH/VPN solution and bittorrent client at the same time on my Pi or will it not have enough oomph?

    Which is better to use: SSH or VPN?

    I'll probably need a DNS solution like no-ip or dyndns, which is better or can you suggest a viable alternative?

    Also you will probably ask why. Well I want to learn more about linux and networking in general for a start. I don't want to have pay for a VPN either. AND I'm fairly sure my GF's email got hacked by someone packet sniffing while she used a public wifi on her phone... She told me after that her password was something like very insecure initially "<commonfirstname><2000>" :(

    I plan on using my moto g, nexus 7 and laptop mainly for remote connections. I've UPC 120mb also.


Comments

  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    If you can get your head around SSH tunneling, SSH does it for me. Less configuration involved. Also check out sshuttle, which Im told is half way between an SSH tunnel and a VPN.
    my Pi or will it not have enough oomph

    :mad:

    Im getting flashbacks of a project I was working on with a developer who didnt think the Pi had enough oomph for the "complicated cryptological algorithms" required for SSH or for tunnelling. He convinced the project manager and we bought hardware that costs 40 times that of a Pi which wasn't as stable.

    Anyway I digress.

    The Pi can easily handle SSH, SSH tunneling, and VPN, so try a few and see which you prefer.


  • Registered Users, Registered Users 2 Posts: 570 ✭✭✭hooplah


    I'm interested in how you get on with this as I'm planning to do the same thing, but I still want to run XMBC on top.

    I had OpenELEC and switched that for Xbian last night.

    Anyway, good luck with the project.


  • Registered Users, Registered Users 2 Posts: 5,949 ✭✭✭A Primal Nut


    Was thinking of doing this but I wonder if leaving the PI on for 24/7 is more cost effective than paying for a vpn service (which also gives you access via other countries).

    Might be cool to pair with a Belkin Wemo Home Automation Switch which should allow you to turn on the raspberry pi remotely, so you wouldn't have to leave the pi on all the time.

    Not an expert on power consumption though, just putting my ideas out there.


  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    Was thinking of doing this but I wonder if leaving the PI on for 24/7 is more cost effective than paying for a vpn service (which also gives you access via other countries).

    Might be cool to pair with a Belkin Wemo Home Automation Switch which should allow you to turn on the raspberry pi remotely, so you wouldn't have to leave the pi on all the time.

    Not an expert on power consumption though, just putting my ideas out there.

    The Pi consumes 5watts and approximately 1 amp.

    To put it in perspective, it consumes in 8 hours what a 40 watt bulb, consumes in 1 hour.


  • Registered Users, Registered Users 2 Posts: 6,393 ✭✭✭AnCatDubh


    syklops wrote: »
    The Pi consumes 5watts

    Electric Ireland have a very handy calculator on their site (bottom of homepage), which if you feed the 5 watts into it, gives you a staggering total of €1.27 per two monthly bill or a whopping €7.62 per year - that's powered on, 24x7x365.

    Sounds a bit too good really :O


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,792 ✭✭✭coillcam


    syklops wrote: »
    The Pi consumes 5watts and approximately 1 amp.

    To put it in perspective, it consumes in 8 hours what a 40 watt bulb, consumes in 1 hour.
    AnCatDubh wrote: »
    Electric Ireland have a very handy calculator on their site (bottom of homepage), which if you feed the 5 watts into it, gives you a staggering total of €1.27 per two monthly bill or a whopping €7.62 per year - that's powered on, 24x7x365.

    Sounds a bit too good really :O
    Was thinking of doing this but I wonder if leaving the PI on for 24/7 is more cost effective than paying for a vpn service (which also gives you access via other countries).

    Might be cool to pair with a Belkin Wemo Home Automation Switch which should allow you to turn on the raspberry pi remotely, so you wouldn't have to leave the pi on all the time.

    Not an expert on power consumption though, just putting my ideas out there.

    Two of the original reasons I want to use the Pi:

    Firstly its €60 max for everything delivered. I probably have some cables or a charger I could save on also.

    Secondly its' power consumption is a fraction of a traditional PC or laptop, as outlined above by ancatdubh. More info here that I had read up on in advance: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=18043.

    Amazon and a lot of the big tech companies are starting to run large parts of their data centers using servers based on mobile CPUs. The lower initial cost of the hardware, lower failures with less mechanical parts, ambient cooling and lower power consumption makes this a no brainer. Obviously this isn't entirely 100% practical for every service offered to run this way from the data centers but it saves a bucket load of cash.

    If my plan didn't work in terms of a torrent client and SSH/VPN, I know that I will fall back on using it as a mini NAS (no GbE though :( ) and/or XBMC. Another option was setting up my own private mini cloud storage. Hell I might end up buying a couple more units and doing it all anyway.


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    I am using my Pi in a similar manner. I have Raspbian installed and I run SSH and openvpn on it. I use a small script to NotifyMyAndroid of it's public IP address daily so I can connect (I do have a DynDNS account too but rarely use it). I use it to socks-proxy when I am away on business and don't fancy the open wireless networks. I also tunnel to other devices on my home network (satellite reciever, TV etc) without any problems.

    I also have a small, Perl based, web app running on it too to manage my multimedia files.

    Overall, tunnelling is fine and basic downloading should be fine. However, if you try and do too much it will grind to a halt. That is, compressing/decompressing files will load it.

    If you can swing it financially I would recommend the U3 (http://hardkernel.com/main/products/prdt_info.php) over the Pi, it destroys it in almost every aspect.


  • Registered Users, Registered Users 2 Posts: 9,605 ✭✭✭gctest50


    Was thinking of doing this but I wonder if leaving the PI on for 24/7 is more cost effective than paying for a vpn service (which also gives you access via other countries).

    .........

    A bit of the tiny amount of power it uses will end up as heat.

    Heat is heat so your (gas) boiler will burn a tiny bit less


  • Registered Users, Registered Users 2 Posts: 20 osotogari


    azzeretti wrote: »
    I am using my Pi in a similar manner. I have Raspbian installed and I run SSH and openvpn on it. I use a small script to NotifyMyAndroid of it's public IP address daily so I can connect (I do have a DynDNS account too but rarely use it). I use it to socks-proxy when I am away on business and don't fancy the open wireless networks. I also tunnel to other devices on my home network (satellite reciever, TV etc) without any problems.

    I also have a small, Perl based, web app running on it too to manage my multimedia files.

    Overall, tunnelling is fine and basic downloading should be fine. However, if you try and do too much it will grind to a halt. That is, compressing/decompressing files will load it.

    If you can swing it financially I would recommend the U3 (http://hardkernel.com/main/products/prdt_info.php) over the Pi, it destroys it in almost every aspect.

    Any chance of sharing that script that you use with NotifyMyAndroid ?


  • Moderators, Technology & Internet Moderators Posts: 1,336 Mod ✭✭✭✭croo


    hooplah wrote: »
    I'm interested in how you get on with this as I'm planning to do the same thing, but I still want to run XMBC on top.

    I had OpenELEC and switched that for Xbian last night.

    Anyway, good luck with the project.
    Sorry to hijack the thread but... I though my rev1 RaspPi struggled with XMBC... are you finding it usable? Do you have a later model with more ram perhaps?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    osotogari wrote: »
    Any chance of sharing that script that you use with NotifyMyAndroid ?

    Sure. Here you go. You will need to register a free NMA account from and get your API key. Then, just change the APIKEY in the script to your own. I have a roppy ISP connection so I run the script on a cron in the morning but if it fails to get to the NWA site to push the IP (it will also have failed to IP lookup too) it will retry every X seconds until it gets you the alert. The retry value can be set at the top of the script.

    From the Pi you need to run:
    sudo apt-get install libwww-perl libxml-simple-perl

    Then just run the script.

    NMA site: http://www.notifymyandroid.com/index.jsp
    #!/usr/bin/perl
    #
    # Easy script to use NotifyMyAndroid to push a device's public IP address
    # Azzeretti 2014
    # Use, modify and ridicule however you wish!
    #
    
    use strict;
    use warnings;
    use LWP::UserAgent;
    use XML::Simple;
    
    ################ Change API key and retry interval as required ###############
    
    my $apikey = 'YOUR_NMA_API_KEY_GOES_HERE';
    my $retry_interval = 30;
    
    ##############################################################################
    my $url    = 'https://www.notifymyandroid.com/publicapi/notify?apikey=';
    my $res;
    $url .= $apikey;
    my $app    = '&application=My_IP';
    my $event  = '&event=IP_Address';
    my $desc   = '&description=';
    my $ua = LWP::UserAgent->new;
    $ua->agent("NotifyMyAndroidIP/1.0");
    my $ip = `wget -O - -q http://ipecho.net/plain`;
    $desc .= $ip;
    my $send = $url . $app . $event . $desc;
    
    SENDURL:
    $res = $ua->get($send);
    
    if ($res->{_rc} == 200 ){
        my $xml = XMLin($res->{_content});
            if($xml->{error}->{code} ) {
            print "Send failed with reason: " . $xml->{error}->{content} . "\n";
            }
            elsif ( $xml->{success}->{code} == 200 ) {
                    print "Success! $xml->{success}->{remaining} alerts left\n"
                }
            
    }
    
    else {print "Failed to connect to NMA site. Assuming network down. Will try again in $retry_interval seconds\n";
          sleep $retry_interval;
          goto SENDURL}
    


  • Registered Users, Registered Users 2 Posts: 570 ✭✭✭hooplah


    croo wrote: »
    Sorry to hijack the thread but... I though my rev1 RaspPi struggled with XMBC... are you finding it usable? Do you have a later model with more ram perhaps?

    I think I got the first model B, I'm not at home now to check the pi itself but it was shipped in July 2012.


  • Registered Users, Registered Users 2 Posts: 20 osotogari


    azzeretti wrote: »
    Sure. Here you go. You will need to register a free NMA account from and get your API key. Then, just change the APIKEY in the script to your own. I have a roppy ISP connection so I run the script on a cron in the morning but if it fails to get to the NWA site to push the IP (it will also have failed to IP lookup too) it will retry every X seconds until it gets you the alert. The retry value can be set at the top of the script.

    From the Pi you need to run:
    sudo apt-get install libwww-perl libxml-simple-perl

    Then just run the script.

    NMA site: http://www.notifymyandroid.com/index.jsp
    #!/usr/bin/perl
    #
    # Easy script to use NotifyMyAndroid to push a device's public IP address
    # Azzeretti 2014
    # Use, modify and ridicule however you wish!
    #
    
    use strict;
    use warnings;
    use LWP::UserAgent;
    use XML::Simple;
    
    ################ Change API key and retry interval as required ###############
    
    my $apikey = 'YOUR_NMA_API_KEY_GOES_HERE';
    my $retry_interval = 30;
    
    ##############################################################################
    my $url    = 'https://www.notifymyandroid.com/publicapi/notify?apikey=';
    my $res;
    $url .= $apikey;
    my $app    = '&application=My_IP';
    my $event  = '&event=IP_Address';
    my $desc   = '&description=';
    my $ua = LWP::UserAgent->new;
    $ua->agent("NotifyMyAndroidIP/1.0");
    my $ip = `wget -O - -q http://ipecho.net/plain`;
    $desc .= $ip;
    my $send = $url . $app . $event . $desc;
    
    SENDURL:
    $res = $ua->get($send);
    
    if ($res->{_rc} == 200 ){
        my $xml = XMLin($res->{_content});
            if($xml->{error}->{code} ) {
            print "Send failed with reason: " . $xml->{error}->{content} . "\n";
            }
            elsif ( $xml->{success}->{code} == 200 ) {
                    print "Success! $xml->{success}->{remaining} alerts left\n"
                }
            
    }
    
    else {print "Failed to connect to NMA site. Assuming network down. Will try again in $retry_interval seconds\n";
          sleep $retry_interval;
          goto SENDURL}
    

    Awesome! Thanks, this should work nicely :)


  • Registered Users, Registered Users 2 Posts: 1,792 ✭✭✭coillcam


    My Pi is en route. Went through amazon in the end for the 512mb B model with an 8GB card and modmypi case. Have everything else I need at home.

    I'll update in a week or so as to how I get on.


  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    Just got the word that we have been accepted to rent an apartment near to my work. No more 90 minute commutes. I've been planning on setting up a decent array, but the new place is quite small, so I think I will be building an array of Pi's with one Pandaboard as the controller. I have a Pandaboard and a pi from a previous job, and I won a second pi at IRISS in November.

    I'm used to being surrounded by systems. It feels almost alien having just my laptop as it is now. For a few years I had an old IBM server sat under the stairs, that was end of life from Eircom. 4 PSUs, 16 Xeon processors, 24 hot swappable drives. It will be nice to have a choice of systems to connect to again.


  • Registered Users, Registered Users 2 Posts: 1,792 ✭✭✭coillcam


    Got my Pi on Friday but haven't had much time to tinker just yet. Just the very basics done so far. Raspbian and Raspbmc installed using NOOBs, SSH'ing in, static IP assigned, small overclock and vnc server setup. Its a pretty amazing little piece of kit.

    Does anyone know of a way for me to reboot from Raspbian and then into Raspbmc without physically being at my Pi/TV during NOOBs boot selection? Is there a command I can run from SSH or a config file I could edit perhaps?

    Should get some time during the week to get back to my original plan :)


  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    coillcam wrote: »
    Got my Pi on Friday but haven't had much time to tinker just yet. Just the very basics done so far. Raspbian and Raspbmc installed using NOOBs, SSH'ing in, static IP assigned, small overclock and vnc server setup. Its a pretty amazing little piece of kit.

    Does anyone know of a way for me to reboot from Raspbian and then into Raspbmc without physically being at my Pi/TV during NOOBs boot selection? Is there a command I can run from SSH or a config file I could edit perhaps?

    Should get some time during the week to get back to my original plan :)

    AFAIK, not without editing your grub config. Why don't you just install XBMC on raspian?


  • Registered Users, Registered Users 2 Posts: 1,792 ✭✭✭coillcam


    syklops wrote: »
    AFAIK, not without editing your grub config. Why don't you just install XBMC on raspian?

    I'd prefer to run XBMC on as close to "bare metal"(not strictly a correct term) as opposed to through raspian. Some of the Pi forums were saying that the CPU idles at 50% on Raspbmc whereas XBMC on Raspbian runs at 90%. I'll definitely test it out and compare the results myself anyway.

    Tonight's plan is to get dynamic DNS up and running for a start, set vncserver to auto-run at boot and if I have time get rtorrent or deluge configured properly.


  • Registered Users, Registered Users 2 Posts: 3,981 ✭✭✭Diarmuid


    If you want XBMC why not try OpenElec. I set it up on a RaspberryPi at the weekend and it's very impressive.

    Speaking of RaspberryPi, this is what my first one does now. And I can ssh into it ;)
    293673.JPG


  • Registered Users, Registered Users 2 Posts: 16,926 ✭✭✭✭Francie Barrett


    I am doing something similar to you, except I am using two Raspberry Pi's, one Pi that runs XBMC and another that runs as my torrent server. I tried to get both the torrent server and XBMC client running on the same Pi, but just couldn't get it going, so went with running each on a different Pi.

    I used the instructions fron the following URL to set up my Torrent server - http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/

    My only problem is that I would like to automatically have completed torrents dropped to a HD that's connected to my XBMC Pi. Unfortunately, I haven't quite figured out how to get my Cron job doing a night cycle where it would SSH the files over :(


  • Advertisement
  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    I am doing something similar to you, except I am using two Raspberry Pi's, one Pi that runs XBMC and another that runs as my torrent server. I tried to get both the torrent server and XBMC client running on the same Pi, but just couldn't get it going, so went with running each on a different Pi.

    I used the instructions fron the following URL to set up my Torrent server - http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/

    My only problem is that I would like to automatically have completed torrents dropped to a HD that's connected to my XBMC Pi. Unfortunately, I haven't quite figured out how to get my Cron job doing a night cycle where it would SSH the files over :(

    Post up your cron config and we will have a look for you.


  • Closed Accounts Posts: 1,788 ✭✭✭White Heart Loon


    I am doing something similar to you, except I am using two Raspberry Pi's, one Pi that runs XBMC and another that runs as my torrent server. I tried to get both the torrent server and XBMC client running on the same Pi, but just couldn't get it going, so went with running each on a different Pi.

    I used the instructions fron the following URL to set up my Torrent server - http://www.howtogeek.com/142044/how-to-turn-a-raspberry-pi-into-an-always-on-bittorrent-box/

    My only problem is that I would like to automatically have completed torrents dropped to a HD that's connected to my XBMC Pi. Unfortunately, I haven't quite figured out how to get my Cron job doing a night cycle where it would SSH the files over :(

    Just torrents, pffft, check out Usenet, it has Sabnzbd, Couchpotato, Sickbeard, NzbDrone, and Headphones software that completely automates downloading everything. It finds and lines up content, downloads, extracts, renames, moves, adds artwork and metadata and sends you notifications when it's done. All are python based multiplatform software, run on any OS. You should easily be able to run them on a pi alongside Deluge.


  • Registered Users, Registered Users 2 Posts: 1,477 ✭✭✭azzeretti


    Just torrents, pffft, check out Usenet, it has Sabnzbd, Couchpotato, Sickbeard, NzbDrone, and Headphones software that completely automates downloading everything. It finds and lines up content, downloads, extracts, renames, moves, adds artwork and metadata and sends you notifications when it's done. All are python based multiplatform software, run on any OS. You should easily be able to run them on a pi alongside Deluge.

    I would not put any of those apps anywhere near a RPi. Certainly Sab and Sickbeard are hungry feckers and use a lot of resources. For the Pi you need NZBGet which is very low resource and as of the latest release does everything Sab does (and in my opinion is better). There is also Showdypi which is a command line alternative to Sickbeard which does the same thing without the bells and whistles.

    If you do go with any of this apps you should make sure you pause all activity when par checking and unrar is running - the Pi will be under a lot of pressure otherwise.


  • Closed Accounts Posts: 1,788 ✭✭✭White Heart Loon


    azzeretti wrote: »
    I would not put any of those apps anywhere near a RPi. Certainly Sab and Sickbeard are hungry feckers and use a lot of resources. For the Pi you need NZBGet which is very low resource and as of the latest release does everything Sab does (and in my opinion is better). There is also Showdypi which is a command line alternative to Sickbeard which does the same thing without the bells and whistles.

    If you do go with any of this apps you should make sure you pause all activity when par checking and unrar is running - the Pi will be under a lot of pressure otherwise.

    Don't bother with Sabnzbd and you lose all the third party extras, addons and integrations it brings. Besides, it will only be slow while repairing and extracting, it won't use much resources ticking over or downloading, anyway, it's a download box, it doesn't need to be fast unless you're trying to make it do other things. I no longer use Sickbeard, NzbDrone is much better and is actively being developed (2-4 updates per month).


  • Registered Users, Registered Users 2 Posts: 16,926 ✭✭✭✭Francie Barrett


    syklops wrote: »
    Post up your cron config and we will have a look for you.
    Cron job seems fine, it's the script that isn't working. Confirmed I can log into my Raspberry Pi using SSH with below credentials. Doesn't work through my script.

    #!/bin/bash

    RASPBERRY_IP = '192.168.0.9'
    RASPBERRY_HD_DIR = '/media/HDDTOGO/Movies'
    USERNAME = 'raspberry'
    PASSWORD = 'pi'

    ftp -n $RASPBERRY_IP <<TRANSFER
    user $USERNAME
    $PASSWORD

    cd $RASPBERRY_HD_DIR
    put *.*

    quit

    TRANSFER
    exit 0


  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    Cron job seems fine, it's the script that isn't working. Confirmed I can log into my Raspberry Pi using SSH with below credentials. Doesn't work through my script.

    #!/bin/bash

    RASPBERRY_IP = '192.168.0.9'
    RASPBERRY_HD_DIR = '/media/HDDTOGO/Movies'
    USERNAME = 'raspberry'
    PASSWORD = 'pi'

    ftp -n $RASPBERRY_IP <<TRANSFER
    user $USERNAME
    $PASSWORD

    cd $RASPBERRY_HD_DIR
    put *.*

    quit

    TRANSFER
    exit 0

    You are uploading files to the Raspberry HD directory?

    Can I suggest:

    scp -r /path/to/files/to/upload/* pi:'raspberry'@raspberry-ip:/media/HDDTOGO/Movies

    Though using the tool sshpass is the recommended way. of passing the password to scp.


  • Registered Users, Registered Users 2 Posts: 16,926 ✭✭✭✭Francie Barrett


    Got my script working. In the end, the username and password were the wrong way around. Doh!


Advertisement