Tutorials for your Raspberry Pi.

Category: Tutorials (page 1 of 2)

Raspberry Pi SSH security – Fail2ban



Raspberry Pi SSH security – Fail2ban

There are a lot of shady people on the internet, scanning IP ranges for vulnerable machines/raspberry pi’s.
With a simple program called Fail2ban you can kick out the bruteforcers.
After 6 failedssh login’s the IP of the client will be blocked by default for 10 minutes.
Your raspberry pi is a lot safer now!

How to:

sudo apt-get update
sudo apt-get install fail2ban


Now fail2ban is installed! Easy isn’t it ?

You can change settings @ /etc/fail2ban/jail.conf
1st picture are the common settings, 2nd picture is specific for SSH.





Have fun!

Raspberry Pi Mount External Harddisk

Harddisk in my case: Normal NTFS formatted.

Connect the hard disk on your Raspberry Pi.

Login with putty, or open a termal.

sudo blkid

You see the hard disk name and his location. Something like /dev/sdxX before it. Remember the /dev/sdxX.

Now make a new folder on your pi.
Example: /home/raspberrypi/hardiskmount/

mkdir /home/raspberrypi/hardiskmount/

now typ:

sudo nano /etc/fstab

Add a new rule:

/dev/sdX /home/raspberrypi/hardiskmount/ ntfs default 0 0

Change the X to your own number from the sudo blkid commando on the first step.

Save the file, and close it. (Control + x)

sudo mount -a


Now navigate to the /home/raspberrypi/hardiskmount/ folder, to use your mounted harddrive!


Have fun!

Raspberry Pi Nagios Monitor System



Nagios monitor system Raspberry Pi

With Nagios you can:

  • Monitor your entire IT infrastructure
  • Spot problems before they occur
  • Know immediately when problems arise
  • Share availability data with stakeholders
  • Detect security breaches
  • Plan and budget for IT upgrades
  • Reduce downtime and business losses

How To install Nagios on the raspberry pi?

Update + Upgrade your rasperry pi:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nagios3

After a while you get this screen, enter a password.


All done? You can access Nagios in your webbrowser:




Have fun!

Raspberry Pi Webserver



Host your own website on the raspberry pi? Yes you can!

You will install the following programs:

  • nginx
  • MySQL
  • PHP5-fpm
  • phpMyAdmin
  • ImagIck
  • vsftpd
apt-get update
apt-get upgrade

Now you are up to date 🙂


Install the mysql server:

sudo apt-get install mysql-server

You will get a screen for entering the mysql password, enter a long and secure password!


sudo apt-get install nginx
sudo service nginx start
sudo apt-get install php5-fpm
sudo apt-get install php5-imagick
sudo nano /etc/php5/fpm/php.ini

Change the rule “upload_max_filesize = 2M” to

"upload_max_filesize = 10M"

Add this rule at the  Dynamic Extensions section:



Control + X to close/save the file.

sudo apt-get install phpmyadmin

At the webserver selection screen press “TAB” on your KEYBOARD
[ENTER] Don’t select apache or lighttpd!

If you get the screen if you want db-config,  choose “Yes”.


The following step is entering your MySQL password, and set a password for phpMyAdmin.




sudo service php5-fpm restart
sudo mkdir /srv/www
sudo chown -R YOURUSERNAME:www-data /srv/www
sudo chmod -R 755 /srv/www
mkdir /srv/www/example.com
cd /srv/www/example.com
mkdir logs
nano logs/access.log (Just make the file, and close it)
nano logs/error.log (Just make the file, and close it)
mkdir public

(Change example.com with your own site-name)

sudo nano /etc/nginx/sites-available/example.com

Add the following info in the file:


server {
    server_name example.com;
    access_log /srv/www/example.com/logs/access.log;
    error_log /srv/www/example.com/logs/error.log;
    root /srv/www/example.com/public/;
    location / {
        index index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    location ~ \.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/example.com/public$fastcgi_script_name;
    location /phpmyadmin {
        root /usr/share/;
        index index.php index.html index.htm;
        location ~ ^/phpmyadmin/(.+\.php)$ {
            try_files $uri =404;
            root /usr/share/;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;
        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            root /usr/share/;
    location /phpMyAdmin {
        rewrite ^/* /phpmyadmin last;


sudo ln -s /etc/nginx/sites-available/yoursitename /etc/nginx/sites-enabled/yoursitename
sudo service nginx restart
nano /srv/www/example.com/public/index.php

Add the following:

<?php phpinfo(); ?>

Control + x to close/save the file.


Have fun!

Raspberry Pi File Transfer – WinSCP

Easy transferring your files from and to your Raspberry Pi, without setting up a FTP server!

Download WinSCP here: http://winscp.net/eng/download.php

If you boot wheezy-raspbian for the first time, enable SSH on the raspi-config screen. Or if you want to get into the config screen again.

 sudo raspi-config


Install Winscp, open it, and enter your Raspberry Pi details.

File protocol: SFTP or SCP. It dont care 🙂
Hostname = Your raspberry pi IP adres
Username: Your raspberry pi username
Password: The password of your raspberry pi username.




Once you are logged in, the left side of the screen is your local computer. The right side is your Raspberry pi!
Drag files from left to right or from right to left to copy files.



Have fun!

Raspberry Pi Screen (Keep your processes running after disconnect)

Raspberry Pi  Screen Tutoria

“Screen” is a program to run one or multiply SSH connections in the background.  The session will keep alive, even if you close your SSH connection.

Install screen:

sudo apt-get install screen

Now you have Screen installed.



Now you see a screen like this:



Press the spacebar / Enter key / Return key to move on.

This screen looks like the same as a normal putty connection. But you are in the “screen” program.

Screen command list:

Ctrl + A + C:  Create a new SCREEN session.
Ctrl + A + N:  Switch to the Next screen session.
Ctrl + A + P:  Switch to the Previous screen session.
Ctrl + A + D:  Detaches a screen session (without killing the processes in it – they continue).


To close a Screen session typ:



If you are in the normal SSH session, and you want to start a virtual screen session with the name “thevirualsession”

screen -S thevirualsession.

Back to the normal ssh session and keep the virtual session alive (Detache):

Control + a + d

If you are in the normal SSH connection, and you want to see all the current screens:

screen -ls

i have 1 “Screen” session open:



And now how to switch to the “Screen” session? Typ:

screen -r 2494.pts-0.raspberrypi

Have fun!

Raspberry Pi Hanewin NFS share KODI – XBMC

Hanewin NFS share – How to setup a nfs share for your Raspberry Pi XBMC mediacenter.

HANEWIN Downloads (Trial) Full non version costs around €19,00)

This has been used successfully on Windows XP,  Vista, Windows 7, Windows 8. Windows 8,1 Windows 10
First:  Add the following ports in your “allow” list, in Windows Firewall.

Windows firewall -> Advaned Settings
—/Inbound Rules -> New Rule -> Port -> TCP ->Specific local port: 1058, 111, 2049
Follow the same stepts for UDP.

And do the same for outbound rules (TCP & UDP)

inbound AND outbound!
TCP/UDP: 1058
TCP/UDP: 111
TCP/UDP: 2049

Start Hanewin NFS server and use these settings:





Edit exports file
My exports file looks like this:

G:\Downloads\movies -readonly -public
F:\Downloads\movies -readonly -public

As you see i use the -readonly & -public option, for a full list of options use this link to the original Hanewin website.

Save the file and hit the “Restart Server” button.


Now on the XBMC side: Add a new NFS share -> click -> clack -> You are done!

You can also use a free nfs server, like: FreeNFS, But i don’t have experience with.

Raspberry Pi Owncloud (Dropbox Clone)



Owncloud is like dropbox, but then local and hosted on your OWN Raspberry Pi!

Features of Owncloud:
Acces your data
Sync your data
share your data
Calendar share
And more!


Here we go!

sudo aptitude install nginx php5-fpm php5-sqlite php5-gd
cd /etc/nginx/sites-available
sudo nano owncloud.vhost

Copy this txt info the owncloud.vhost file

# redirect http to https.
#server {
#  listen 80;
#  server_name owncloud.example.org;
#  rewrite ^ https://$server_name$request_uri? permanent;  # enforce https
# owncloud (ssl/tls)
server {
  #listen 443 ssl;
  listen 80;
  #ssl_certificate /etc/nginx/certs/server.crt;
  #ssl_certificate_key /etc/nginx/certs/server.key;
  #server_name localhost;
  root /usr/share/nginx/www/owncloud;
  index index.php;
  client_max_body_size 1000M; # set maximum upload size
  # deny direct access
  location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
    deny all;
  # default try order
  location / {
    try_files $uri $uri/ @webdav;
  # owncloud WebDAV
  location @webdav {
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param HTTPS on;
    include fastcgi_params;
  # enable php
  location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    #fastcgi_param HTTPS on;
    include fastcgi_params;

sudo ln -s /etc/nginx/sites-available/owncloud.vhost /etc/nginx/sites-enabled/
sudo nano /etc/php5/fpm/php.ini



Hit control + X to close/save the file.

Now download Owncloud.
Check the website for the newest release: https://owncloud.org/install/#instructions-server

cd /home/pi
wget https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
sudo tar -xjf owncloud-9.0.0.tar.bz2



sudo chown -R www-data:www-data owncloud
sudo mkdir /usr/share/nginx/www/owncloud
sudo mv owncloud /usr/share/nginx/www/
sudo /etc/init.d/nginx start
sudo nano /etc/php5/fpm/php.ini

And change the

upload_max_filesize = 2M (from 2MB to the max size you want)
post_max_size = 6M (To the size you want)


Reboot your raspberry pi:

Sudo reboot now

Now acces the Owncloud page! http://RASPBERRYPIIPADRES



Raspberry Pi Ambilight – Boblight – XBMC



Raspberry Pi Ambilight – Boblight – XBMC

This guide will tell you how to get Boblight & Raspbmc & xbmc running on the same Raspberry Pi
to make an awesome media centre experience for ~ €50!

The Home of PiBob! http://pibob.nadnerb.co.uk/

Raspberry Pi Bittorrent Sync – Bitsync




With Bitsync you can sync folders/files aross computers, tablets, phones., like Dropbox.  But your data with bitsync is private and secure on your own harddrives, data carrier.

Pro’s of Bitsync:

  • All your data in own hands, no 3th party “cloud”
  • The only size limitation is your own hard drive. Files can be 1kb, or even 1TB!


  • If you have 2 devices. 1 PC and 1 smartphone. If the pc is off the smartphone can’t sync because the PC is off.

That’s why we use the Raspberry pi. It’s always on with low power consumption.

How to install Bitsync on the Raspberry Pi:

sudo nano /etc/apt/sources.list.d/btsync.list

past following lines:

deb http://debian.yeasoft.net/btsync wheezy main contrib non-free
deb-src http://debian.yeasoft.net/btsync wheezy main contrib non-free

Control + x to close/save the file.

sudo apt-get update
sudo apt-get install btsync

Config: Default Sync instance? Yes.


Port nr? Pick something random: for example: 45454


Portmapping UPNP: Own choice, If you don’t use UPNP you must manually open the port in your modem/router. For now we choose YES.



Bandwidth: 0 = No limit.




Upload Bandwidth:



Web interface: Leave it. Hit enter key.



Web interface port: 8888



Specify a password for the interface:



Browse to:


Add a folder, Generate a private key, You will need enter this key on your smartphone/pc to sync with the just created folder.





How to stop Btsync?

sudo service btsync stop

Bit torrent sync will auto start on raspberry pi boot up.


Have  fun!


Older posts

© 2016 Raspberrypihelp

Theme by Anders NorenUp ↑