Backup ftp server

Written by pmd - - no comments

Information from


The following command recursively downloads your site with all its files and folders from FTP server and saves them to the current directory.

wget -r -l 0 -nH -X folder_to_skip


option description
user FTP username
pass FTP password IP address or domain name of an FTP server
-r Recursive retrieving
-l Maximum recursion depth (0 = unlimit) (default = 5)
-nH Disable generation of host-prefixed directories
-X exclude a list of directories


Now you can compress the folder with your site as follows:

tar -czf site-backup-$(date +%Y%m%d-%H%M%S).tar.gz

Install pluxml on raspberry pi

I am using nginx + php7 + pluxml followinf these two links:


Transmission exclusively using VPN

Written by pmd - - no comments

I would like to have my transmission client to exchange data only through a VPN.


First of all, it is necessary to set some rules so the 'debian-transmission' user (running transmission) can only route through the VPN:

# 'debian-transmission' user only accepted through 'tun0'
# after these 3 first rules, transmission cannot access internet
sudo iptables -A OUTPUT -m owner --uid-owner 'debian-transmission' -o tun0 -j ACCEPT
sudo iptables -A OUTPUT -m owner --uid-owner 'debian-transmission' -o lo -j ACCEPT
sudo iptables -A OUTPUT -m owner --uid-owner 'debian-transmission' -j REJECT
# marking all packets used by users different than 'debian-transmission' with '42'
sudo iptables -t mangle -A OUTPUT -m owner ! --uid-owner 'debian-transmission' -j MARK --set-mark 42
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
net.ipv4.conf.wlan0.rp_filter = 2 # reverse path filtering

FYI: these rules will be set only until next reboot.

If you are sure that these iptables rules we set are OK, you can make them permanent (resistant to reboot):

sudo apt-get install iptables-persistent
sudo dpkg-reconfigure iptables-persistent # if already installed

Tap yes to both prompts. Done, these rules are persistent: transmission cannot communicate without an active tun0 interface (VPN).


The strategy I used is this one:

  • all packets not marked '42' following main route table
  • all packets marked '42' following route table named '42'

Create a systemd .service to create and populate route table '42' when Pi3 starts:

sudo nano /etc/systemd/system/copy_route_pmd.service

We will wait to find an IP address containing "192", then we will create the new table "42" and copy all rules from main table to "42" table.

Description=Copy the route of main table to table 42 at system startup
After =
Wants =

ExecStart=/bin/bash -c "while ! [[ -n $(ifconfig | grep 192) ]]; do sleep 1; done; ip rule add fwmark 42 table 42; ip route show table main | while read LINE; do ip route add $LINE table 42; done"


We reload systemd to update with the new service we made and make the service execute at system startup.

# Reloading
systemctl daemon-reload # Run if *.service file has changed
# Try the new service 
sudo systemctl start copy_route_pmd.service
# If OK (check tables main and 42), set service to execute at startup
sudo systemctl enable copy_route_pmd.service

Now, debian-transmission will use main table to route packets, and users different than debian-transmission will use the table 42.

Link to article to check routes



Configure openvpn

Make sure that you let openvpn push new rules in main route table in order to use the VPN.

Now that openvpn made up tun0 interface, check that the routes are respected:

wget -qO-
sudo -u debian-transmission wget -qO-

These two commands will return different IP address!


Install transmission

Verify that transmission-daemon is run by correct user:

top -u debian-transmission

Check your visible torrent IP with this:

Access to transmission web interface will require nginx


Install nginx:

sudo apt-get install nginx

Edit the default configuration:

sudo nano /etc/nginx/sites-available/default

Replace section locotion by this :

location /transmission {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Access your interface worldwide using: http://yourIPadress/transmission/web/

DNS leak

To prevent DNS leak and/or not to rely on the router you are connected to the internet, modify the file:

sudo nano /etc/resolv.conf.head
#OpenDns Servers
#Google Servers

In fact I want to set the DNS servers directly in the Raspberry Pi, because it allows me to remove the default route to the router in table 42 and keep it as tidy as possible.

Then reboot the Pi 3:

sudo reboot

You can now check that these are the first DNS server is use:

pi@raspberrypi:~ $ cat /etc/resolv.conf
# Generated by resolvconf
#OpenDns Servers
#Google Servers
domain home

From your Pi3, check the DNS leakage from this website:

Create a torrent on WNR3500L with Transmission

Written by pmd - - no comments

Here is the command line to use if you wanna create a torrent:

transmission-create -o /tmp/mnt/PMD/your_futur.torrent -c "your comments here" -t udp:// -t udp:// /tmp/mnt/PMD/

Then you need to:

  1. move your in your transmission download folder
  2. add the created torrent your_futur.torrent in your transmission using the web interface by example.
  3. in transmission web interface, right click on the torrent, and choose "verify local data".

You are set to share your file(s) !

Send email from WNR3500L

Written by pmd - - no comments

Router is running Tomato by Shibby.

First install Optware (see how to install here steps 1 to 6).

Then install msmtp:

ipkg install msmtp

Edit the configuration file (you may have to install nano "ipkg install nano"):

nano /opt/etc/msmtprc
account default
port 587
auth on
password password
auto_from on
tls on
tls_starttls on
#tls_trust_file /opt/etc/ca-certificates.crt
# Use "tls_certcheck off" if you don't have ca-certificates.crt file.
tls_certcheck off
# Log to a separate file; use with no options to disable this feature
# logfile /opt/logs/msmtp
# Uncomment if you want to log to syslog facility, which is disabled by default
syslog LOG_MAIL

Test it:

echo -e "Subject: subject \n\nThis is the body" | msmtp

Done :)

If you use Gmail you might need to allow less secure apps:

Send email from your Raspberry Pi 3

Written by pmd - - no comments

Simple SMTP is a simple MTA (Mail Transport Agent) to deliver mail from a computer to a mail hub (SMTP server). It can be usefull to send result of your Cron jobs.

Install ssmtp:

sudo apt-get install ssmtp

Configure it:

sudo nano /etc/ssmtp/ssmtp.conf

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named

# Where will the mail seem to come from?

# The full hostname

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address

Configure the account sending the email:

sudo nano /etc/ssmtp/revaliases

# sSMTP aliases
# Format:       local_account:outgoing_address:mailhub
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

Try to send an email:

echo "email for test" | ssmtp -vvv

If you use Gmail you might need to allow less secure apps:

Timer to restart Raspberry Pi 3

Written by pmd - - no comments

A timer just in case shit happens whaile playing through ssh:

sudo nano /home/pi/
for (( c=$1; c>1; c-- ))
   echo -n "Reboot in $c minute(s)...  "
   date +%H:%M
   sleep 1m
echo "Reboot in 1 minute(s)..."
sleep 1s
for (( c=59; c>0; c-- ))
   echo -e "\e[101mReboot in $c second(s)... (CTRL+C to cancel rebooting)\e[49m"
   sleep 1s
echo -e "\e[101mReboot in $c second(s)...\e[49m"
echo -e "\e[101mREBOOT!!!\e[49m"
sudo reboot

Then need to start it in a screen:

screen bash /home/pi/ number_of_minutes

Subsonic on Raspberry Pi 3

Written by pmd - - no comments

Install java:

sudo apt-get install openjdk-8-jre

Download the Subsonic .deb package and install it:

sudo dpkg -i subsonic-x.x.deb

Change user (i have set pi instead of root) :

sudo nano /etc/default/subsonic

For troubleshooting interesting files are here: /var/subsonic

It was interesting because it allowed me to understand why Subsonic web interface was OK but impossible to play a file :

cat /var/subsonic/subsonic.log
[2018-01-14 10:59:44,539] INFO TranscodeInputStream - Starting transcoder: /var/subsonic/transcode/ffmpeg -i /home/pi/Music/Paul Kalkbrenner - Berlin Calling/07_Paul_Kalkbrenner_-_Torted_Original Mix.mp3 -map 0:0 -b:a 128k -v 0 -f mp3 -
[2018-01-14 10:59:44,551] INFO InputStreamReaderThread - (/var/subsonic/transcode/ffmpeg) /var/subsonic/transcode/ffmpeg: 1: /var/subsonic/transcode/ffmpeg: Syntax error: "(" unexpected

It was a problem linked with ffmpeg. I think the problem comes from the fact that ffmpeg given in deb is made for ubuntu/debian but probably not ARM processor. THis is why I install ffmpeg from repository and then linked Subsonic folder to this ffmpeg freshly installed:

sudo apt-get install ffmpeg
sudo rm /var/subsonic/transcode/ffmpeg
sudo ln -s /usr/bin/ffmpeg /var/subsonic/transcode/ffmpeg

Restart Subsonic:

sudo service subsonic restart

Configure Subsonic using web interface and admin account.

It worked! I could play my music from Astana, Kazakhstan while it was actually stocked in my Raspberry in Paris!

In my opinion it works quiet nice! Not laggy I mean.

Samba on Raspberry Pi 3

Written by pmd - - no comments

Install samba:

sudo apt-get install samba

Edit configuration file:

sudo nano /etc/samba/smb.conf
# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
interfaces = wlan0
bind interfaces only = yes
comment = Samba sharing on Raspberry Pi
path = /home/pi/Downloads
writable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777
share modes = yes

Let everyone read and write on /home/pi/Downloads:

sudo chmod -R 777 /home/pi/Downloads

Restart samba:

sudo /etc/init.d/samba restart

It should be visible in windows Networks.

ddclient on Raspberry Pi 3

Written by pmd - - no comments


sudo apt-get install ddclient

Configure for for two different service with two different website to check IP adress:

sudo nano /etc/ddclient.conf

# Configuration file for ddclient generated by debconf
# /etc/ddclient.conf
use=web,, web-skip='Current IP Address: '

## DtDNS (
#use=web,, web-skip='Current IP Address: ',


To run ddclient as a daemon, set run_daemon to 'true' in /etc/default/ddclient.

Once it is configured as daemon, restart it:

sudo /etc/init.d/ddclient restart

To debug :

sudo ddclient -daemon=0 -debug -verbose -noquiet (-force)

Route with raspian (debian)

Written by pmd - - no comments

I only want to have some process owned by specific users to use the VPN. This means two route table, or more.


Create a new table "42" for marked packet:

sudo ip rule add fwmark 42 table 42

List all route table:

ip rule list
0:      from all lookup local
32765:  from all fwmark 0x2a lookup 42
32766:  from all lookup main
32767:  from all lookup default

Delete table 42:

sudo ip rule del fwmark 42 table 42

Show "main" table route:

ip route show table main
default via dev wlan0 src metric 303 dev tun0 proto kernel scope link src dev wlan0 proto kernel scope link src metric 303

Add a default route in table 42:

sudo ip route add via dev tun0 table 42

Delete the default route in table 42:

sudo ip route del via dev tun0 table 42

You can delete all routes of a specific table:

sudo ip route flush table 42

Copy all route from table main to table 42:

ip route show table main | while read LINE; do sudo ip route add $LINE table 42; done
Rss feed of the articles