Set up Autossh with systemd

Autossh is a great tool that is useful in establishing a persistent encrypted reverse tunnel between two computers.

A case for autossh

Let us say that you have a static IP on the internet and your friend (or relative) that always needs help fixing his computer has a dynamic IP address (constatly changes).  Whenever your friend (or relative) needs their computer fixed you could run to their house and fix it… or you could figure out a way to connect to their computer to fix it.  Now your friend (or relative) probably doesn’t know how to open ports on their router or may not be able to, so how could you make a connection between their computer and yours?…  Enter SSH tunneling…  With ssh you could have your friend (or relative) connect to your computer and establish a reverse tunnel back to them (even on Windows with PUTTY), but again this is the person who is not that good with computers.

We need to make something that is bulletproof, something that you could drop at your friend’s (or relative’s) house and that it does everything by itself.  This is where autossh comes into play.

With autossh running on a simple Linux box (maybe a Raspberry Pi) you can accomplish what is required to establish a persistent tunnel between your friend’s (or relative’s) network and yours.

Another scenario would be that you want to set up an off-site backup of you important data at a friend’s house, but you don’t want to mess about in their router configuration.  You want to give them something they can just plug into their network and turn on.  Autossh can establish a reverse tunnel from their network to your network and you can just use any of the myriad of network sync tools to accomplish your off-site backup.

How to install and configure autossh with systemd

Before we begin we need to make the following assumptions.

  1. Autossh will be running in a computer named “autossh_server” on a different network.
  2. The computer we want to use as our gateway to the other network via the autossh tunnel is named “otherserver”.
  3. We have at least one account (user1) on all computers and root privileges in order to change system configurations files.
  4. We are using Debian Stretch (or a similar distro like Raspbian)
  5. We will run autossh as a service under a user named “autossh”.

We begin by installing autossh in “autossh_server”.

# apt-get install autossh

In this example I’ve chosen “autossh” as the user that the autossh service will run as. We can create the user by executing the following command:

# adduser autossh

Even though the adduser command made a home directory when we created the “autossh” user,  this is a service and we don’t want it to use a home directory in the “/home” folder.  So lets create a folder named “autossh” in the “/var/run/” directory. Create the directory with the following command:

# mkdir /var/run/autossh

Now we make sure that the “autossh” user and the “autossh” group have ownership of the “/var/run/autossh” directory.

# chown autossh:autossh /var/run/autossh

Since “/var/run” is a directory usually mounted as tmpfs anything that is written to “/var/run/autossh” will be effectively destroyed on reboot. Because of this, we need a place to store keys for autossh and since we are running it as a service we might as well use a directory in “/etc”. Create the “/etc/tunnel” directory.

# mkdir /etc/tunnel
# chown autossh:autossh /etc/tunnel
# chmod 700 /etc/tunnel

For the initial setup we are going to use the “/home/autossh” directory.  Logout of the root account and login as the autossh user.  Make sure that you are in the autossh user directory (run “pwd”; it should return “/home/autossh”) and run the following as the “autossh” user:

$ ssh-keygen -t rsa -b 4096

This create an 4096 bit key.  Once it finishes do the following while still the user “autossh” and where “user1” is a user in the server “otherserver”, running the ssh daemon:

cat .ssh/id_rsa.pub | ssh user1@otherserver 'cat >> .ssh/authorized_keys'

This command basically logs into the remote server (“otherserver”) from the “autossh” user account using the “user1” account on the remote server and transfers the authorizing key to that account.  This allows for future logins to be accomplished without having to enter a password.  It also takes care of the initial registration of the remote server’s key (answer “yes” when prompted).

If you get an error like “bash: .ssh/authorized_keys: No such file or directory” ensure that the “.ssh” directory exists in the home directory of the user in “otherserver” and re-run the previous command.

Now we need to move the contents of the “.ssh” directory to its new home in /etc/tunnel:

$ cp -Rp .ssh /etc/tunnel
$ chmod -R 700 /etc/tunnel

The two above commands copy the newly created cryptographic keys to “/etc/tunnel” and lock down the directory so that it is only readable/writable/executable by the owner, in this case the “autossh” user.

Setting up the configuration in systemd

Now return to being root and create “/etc/default/autossh” with the following content:
##############################################
#Specifies how long ssh must be up before we
#consider it a successful connection
AUTOSSH_GATETIME=0
#Sets the connection monitoring port.
#A value of 0 turns the monitoring function off.
AUTOSSH_PORT=0
AUTOSSH_LOGLEVEL=7
AUTOSSH_LOGFILE=/var/run/autossh/user_ssh_error.out
SSH_OPTIONS="-N -o 'ServerAliveInterval 60' -o 'ServerAliveCountMax 3' -p 22 -R 20022:localhost:22 user@otherserver -i /etc/tunnel/.ssh/id_rsa"
###########################################

On the above configuration, notice the line that says:

SSH_OPTIONS="-N -o 'ServerAliveInterval 60' -o 'ServerAliveCountMax 3' -p 22 -R 20022:localhost:22 user@otherserver -i /etc/tunnel/.ssh/id_rsa"

This are the options you are passing to ssh.  The “ServerAliveInterval 60” ensures that every 60 seconds a null packet is sent to keep the connection alive.  The “ServerAliveCountMax 3” set to three the number of server alive messages that may be sent without getting a reply.  The “-p 22” is the port that the remote ssh server is listening on (ssh usually is at port 22).  The “-R 20022:localhost:22” is how we set up the reverse tunnel; in this instance  port 20022 on “otherserver” system connects you to port 22 on “autossh_server”.  You can add any other ports or even forward connections from “autossh_server” to other systems on its network.

For example:

Adding “-R 20080:httpserver:80” would take anything coming into port 20080 of “otherserver” and forward it to port 80 on a system called “httpserver” in the same network as “autossh_server”.

Also, “-R 20089:Windows_box_X:3389” would take anything coming into port 20089 of “otherserver” and forward it to port 3389 on “Windows_box_X”.  Port 3389 is the Windows Remote Desktop Protocol port, so by adding that little line now you can RDP into a windows box on another network over an encrypted tunnel from a system in your local network.

Now to continue with configuration, create “/lib/systemd/system/autossh.service” with the following content:

#############################################
[Unit]
Description=autossh
Wants=network-online.target
After=network-online.target

[Service]
#Type=simple
User=autossh
EnvironmentFile=/etc/default/autossh
ExecStart=/usr/bin/autossh $SSH_OPTIONS
Restart=always
RestartSec=60

[Install]
WantedBy=multi-user.target
#################################################

Now, we can create a soft link in /etc/systemd/system:

# ln -s /lib/systemd/system/autossh.service /etc/systemd/system/autossh.service

Try out the connection as the autossh user:

$ ssh user1@otherserver

If you can ssh in without a password then everything is working as it should.

To further lock down the autossh user, in /etc/passwd change:

autossh:x:1001:1001:autossh,,,:/home/autossh:/bin/bash

to:

autossh:x:1001:1001:autossh,,,:/var/run/autossh:/bin/false

What we are doing here is changing the value for the home directory of the “autossh” user from ” /home/autossh” to “/var/run/autossh” and changing the default shell from “/bin/bash” to “/bin/false”.   As stated before, using “/var/run/autossh” as home ensures its contents is always reset to nothing on reboot.  By changing the default shell value from “/bin/bash” to “/bin/false” we make sure that the “autossh” user is not able to log into the box in any manner.

As started before the contents of “/var/run” doesn’t survive reboot, we need to ensure that the “/var/run/autossh” is created on boot every time.  To do this we need to create a file called autossh.conf in /usr/lib/tmpfiles.d with the following content:

#########################################
d /var/run/autossh 0700 autossh autossh
L /var/run/autossh/.ssh - - - - /etc/tunnel/.ssh
##############################################

What follows the “d” basically mean create the directory “/var/run/autossh” with the permisions set at 0700 and owned by user “autossh” and group “autossh”.  All that follows the “L” means to link the /etc/tunnel/.ssh directory to /var/run/autossh/.ssh.  All this ensures that everything is where it needs to be after a reboot.

Before we can start our service, we have to ask systemd to reload all unit files:

$ sudo systemctl daemon-reload

Now we enable the autossh service:

$ sudo systemctl enable autossh

Before we reboot and test everything out we need to also make some changes to “otherserver” that will allow anyone to connect to the forwarded ports.

Assuming that you are using OpenSSH as you ssh daemon, log into your “otherserver” and edit /etc/ssh/sshd_config.  Change:

#GatewayPorts no

To:

GatewayPorts yes

Also ensure that the parameter is not commented.  Daemons other than OpenSSH should have similar settings.  Restart the OpenSSH daemon or reboot.  Also reboot the computer running autossh.

Once the reboot is complete, we can check the status on the computer running autossh with:

$ sudo systemctl status autossh

If there are any problems, check /var/run/autossh/user_ssh_error.out

Now to test it out…  if you ssh from any machine into “otherserver” using port 20022 you will actually be connected to port 22 on “autossh_server”.

In essence the following command on your local network:

$ ssh -p20022 user1@otherserver

connects you to a computer on a remote network without the need to know the actual IP address of that computer.

 

Installing xrdp 9.4 and xorgxrdp 2.4 on Debian Stretch

This is similar to the other two previous xrdp and xorgxrdp how-tos, just needed to adjust for newer versions.

This how-to is based on the install instructions from XRDP’s github pages for installing on Debian 8.

Install xrdp’s dependencies:

$ sudo apt-get install git autoconf libtool pkg-config gcc g++ make libssl-dev libpam0g-dev libjpeg-dev libx11-dev libxfixes-dev libxrandr-dev flex bison libxml2-dev intltool xsltproc xutils-dev python-libxml2 g++ xutils libfuse-dev libmp3lame-dev nasm libpixman-1-dev xserver-xorg-dev

Get the xrdp and xorgxrdp sources:

$ mkdir -p GIT-sources/neutrinolabs
$ cd GIT-sources/neutrinolabs
$ wget https://github.com/neutrinolabs/xrdp/releases/download/v0.9.4/xrdp-0.9.4.tar.gz
$ wget https://github.com/neutrinolabs/xorgxrdp/releases/download/v0.2.4/xorgxrdp-0.2.4.tar.gz

Building and installing xrdp:

$ cd GIT-sources/neutrinolabs
$ tar xvfz xrdp-0.9.4.tar.gz
$ cd xrdp-0.9.4
$ ./bootstrap
$ ./configure --enable-fuse --enable-mp3lame --enable-pixman --enable-sound
$ make -j2
$ sudo make install
$ sudo ln -s /usr/local/sbin/xrdp{,-sesman} /usr/sbin

Building and installing xorgxrdp:

$ cd GIT-sources/neutrinolabs
$ tar xvfz xorgxrdp-0.2.4.tar.gz
$ cd xorgxrdp-0.2.4
$ ./bootstrap
$ ./configure
$ make -j2
$ sudo make install

Generate keys:

$ sudo xrdp-keygen xrdp auto 2048

Building the pulseaudio modules:

$ cd ~
$ mkdir -p Release-sources/pulseaudio
$ cd Release-sources/pulseaudio
$ sudo apt-get install dpkg-dev
$ sudo apt-get source pulseaudio
$ sudo apt-get build-dep pulseaudio

Change the permisions on the pulseaudio directory to your user:

$ sudo chown -R [USER]:[GROUP] pulseaudio-10.0
$ cd pulseaudio-10.0
$ ./configure

In change directory to “~/GIT-sources/neutrinolabs/xrdp-0.9.3/sesman/chansrv/pulse”

$ cd ~
$ cd GIT-sources/neutrinolabs/xrdp-0.9.4/sesman/chansrv/pulse

Edit the Makefile with your favorite editor and point it to the sources for pulseaudio by changing:

PULSE_DIR = /tmp/pulseaudio-10.0

to:

PULSE_DIR = ../../../../../../Release-sources/pulseaudio/pulseaudio-10.0

then:

$ make -j2

If the build is successful , copy the 2 modules to /usr/lib/pulse-10.0/modules.

$ sudo cp module-xrdp*.so /usr/lib/pulse-10.0/modules

Check the /usr/lib/pulse-10.0/modules directory:

$ ls -al /usr/lib/pulse-10.0/modules

If necessary, fix the ownership and permissions on the two modules:

$ cd /usr/lib/pulse-10.0/modules
$ sudo chown root:root module-xrdp-s*.so
$ sudo chmod 644 module-xrdp-s*.so

The modules are named module-xrdp-sink.so and module-xrdp-source.so

Enable the services:

$ sudo systemctl enable xrdp.service
$ sudo systemctl enable xrdp-sesman.service

Fixes for possible issues:

To run it as terminal server (also useful for Guacamole) add allowed_users=anybody to /etc/X11/Xwrapper.config to allow anybody to start X

To fix the thinclient_drives share error when connected via RDP to the client:

$ sudo umount thinclient_drives

logout and re-login via rdp

 

Installing xrdp 9.3.1 and xorgxrdp 2.4 on Debian Stretch

This is similar to the previous xrdp and xorgxrdp how-to, it is just adjusting to the newer versions of all the pieces of software.

This how-to is based on the install instructions from XRDP’s github pages for installing on Debian 8.

Install xrdp’s dependencies:

$ sudo apt-get install git autoconf libtool pkg-config gcc g++ make libssl-dev libpam0g-dev libjpeg-dev libx11-dev libxfixes-dev libxrandr-dev flex bison libxml2-dev intltool xsltproc xutils-dev python-libxml2 g++ xutils libfuse-dev libmp3lame-dev nasm libpixman-1-dev xserver-xorg-dev

Get the xrdp and xorgxrdp sources:

$ mkdir -p GIT-sources/neutrinolabs
$ cd GIT-sources/neutrinolabs
$ wget https://github.com/neutrinolabs/xrdp/releases/download/v0.9.3.1/xrdp-0.9.3.1.tar.gz
$ wget https://github.com/neutrinolabs/xorgxrdp/releases/download/v0.2.4/xorgxrdp-0.2.4.tar.gz

Building and installing xrdp:

$ cd GIT-sources/neutrinolabs
$ tar xvfz xrdp-0.9.3.1.tar.gz
$ cd xrdp-0.9.3.1
$ ./bootstrap
$ ./configure --enable-fuse --enable-mp3lame --enable-pixman --enable-sound
$ make -j2
$ sudo make install
$ sudo ln -s /usr/local/sbin/xrdp{,-sesman} /usr/sbin

Building and installing xorgxrdp:

$ cd GIT-sources/neutrinolabs
$ tar xvfz xorgxrdp-0.2.4.tar.gz
$ cd xorgxrdp-0.2.4
$ ./bootstrap
$ ./configure
$ make -j2
$ sudo make install

Generate keys:

$ sudo xrdp-keygen xrdp auto 2048

Building the pulseaudio modules:

$ cd ~
$ mkdir -p Release-sources/pulseaudio
$ cd Release-sources/pulseaudio
$ sudo apt-get install dpkg-dev
$ sudo apt-get source pulseaudio
$ sudo apt-get build-dep pulseaudio

Change the permisions on the pulseaudio directory to your user:

$ sudo chown -R [USER]:[GROUP] pulseaudio-10.0
$ cd pulseaudio-10.0
$ ./configure

In change directory to “~/GIT-sources/neutrinolabs/xrdp-0.9.3/sesman/chansrv/pulse”

$ cd ~
$ cd GIT-sources/neutrinolabs/xrdp-0.9.3.1/sesman/chansrv/pulse

Edit the Makefile with your favorite editor and point it to the sources for pulseaudio by changing:

PULSE_DIR = /tmp/pulseaudio-10.0

to:

PULSE_DIR = ../../../../../../Release-sources/pulseaudio/pulseaudio-10.0

then:

$ make -j2

If the build is successful , copy the 2 modules to /usr/lib/pulse-10.0/modules.

$ sudo cp module-xrdp*.so /usr/lib/pulse-10.0/modules

Check the /usr/lib/pulse-10.0/modules directory:

$ ls -al /usr/lib/pulse-10.0/modules

If necessary, fix the ownership and permissions on the two modules:

$ cd /usr/lib/pulse-10.0/modules
$ sudo chown root:root module-xrdp-s*.so
$ sudo chmod 644 module-xrdp-s*.so

The modules are named module-xrdp-sink.so and module-xrdp-source.so

Enable the services:

$ sudo systemctl enable xrdp.service
$ sudo systemctl enable xrdp-sesman.service

Fixes for possible issues:

To run it as terminal server (also useful for Guacamole) add allowed_users=anybody to /etc/X11/Xwrapper.config to allow anybody to start X

To fix the thinclient_drives share error when connected via RDP to the client:

$ sudo umount thinclient_drives

logout and re-login via rdp

 

Lego Batman — Making the minifigure look more like it does in the movie

My son has a fascination with Lego Batman.  Ok, I may have a bit to do with his fascination with Lego Batman, I’m the one that taught him to play it on our very old (but still functional) Wii.  When the Lego Batman movie came out we took him to see it and in the days after my wife got him several minifigres related to it.

Looking at the Batman minifigure, it irked me a bit that in the Lego Batman Movie, Batman’s eyes look like they light up, but the real Lego minifigure does not have light up eyes. Since my wife managed to score more than one Batman minifigure I decided to “enhance” one of them to look more like the movie.

The process was crude and simple.  I basically cut a slit into the head of the minifigure using the dremel.  The slit is in the same general area where the cut-outs for the eyes on Batman’s mask line up.  I then proceeded to grind down a blue LED to fit into the minifigure’s head.  The only reason I chose to use a blue LED is because I have a bunch of them left over from other projects.

Once the LED was stuffed into the head and light was shining out from the slit, it was time to make some hole in the minifigure’s body to accommodate the wires to power the LED.  Initially I thought of just stuffing a small battery into the minifigure’s chest, I quickly gave up on that idea (not much room in there).  Instead I ran wires down a hole I drilled into the “neck ” of the minifigure, then down a hole I drilled into one of the hips and finally out through the bottom of one of the legs into a hole I also drilled into a Lego brick.  The next step is building a small power supply to stuff into the Lego brick (although I may end up using more than one).

Overall the effect is close to what is seen in the movie [insert picture].  Of course the minifigure is no longer useful as a toy…  It is now more of a “showpiece”…

Lego Batman

Pydio 8 with PHP 7 and SSL on Debian Stretch

Installing all dependencies:

# apt install mysql-server php7.0 php7.0-fpm php7.0-mysql php7.0-curl php7.0-json php7.0-gd php7.0-intl php7.0-mbstring php7.0-xml php7.0-zip php7.0-exif php7.0-apcu
apt install libapache2-mod-php

Ensure that apache support for PHP7 is enabled:

# a2enmod php7.0

Installing Pydio:

Download the installation archive.  Choose the Pydio Community Tar.gz archive.

Untar the archive into /var/www/html:

# cd /var/www/html
# tar -xvzf pydio-core-8.0.1.tar.gz

Fix permisions on folders:

# chown -R root:root pydio-core-8.0.1
# chown -R www-data:www-data pydio-core-8.0.1/data/

Create a symlink to the Pydio installation:

# ln -s pydio-core-8.0.1 pydio

In /etc/php/7.0/apache2/php.ini change:

output_buffering = 4096

to:

output_buffering = off

Creating self-signed certificates for Pydio:

# openssl req -x509 -nodes -days 1460 -newkey rsa:2048 -keyout /etc/ssl/private/pydio-selfsigned.key -out /etc/ssl/certs/pydio-selfsigned.crt
# openssl x509 -in /etc/ssl/certs/pydio-selfsigned.crt -out /etc/ssl/certs/pydio-selfsigned.pem -outform PEM

Configuring Apache for SSL:

Enable ssl on apache:

# a2enmod ssl

In the /etc/apalche2/sites-enabled directory:

# rm 000-default.conf
# ln -s ../sites-available/default-ssl.conf default-ssl.conf

In default-ssl.conf change the follwing line from:

SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem

To:

SSLCertificateFile /etc/ssl/certs/pydio-selfsigned.pem

Also change the following line from:

SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

To:

SSLCertificateKeyFile /etc/ssl/private/pydio-selfsigned.key

Configuring Apache for Pydio:

Create a configuration file on /etc/apache2/conf-available:

# cd /etc/apache2/conf-available
# vi pydio.conf

In pydio.conf add the following:

Directory /var/www/html/pydio>
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>

Once finished creating /etc/apache2/conf-available/pydio.conf create a symlink to it in /etc/apache2/conf-enabled:

# cd /etc/apache2/conf-enabled
# ln -s ../conf-available/pydio.conf pydio.conf

Restart Apache:

# systemctl restart apache2

Configuring MySQL/MariaDB:

Setup a password for Mysql/Mariadb (follow the prompts):

# mysql_secure_installation

Creating the database and user for Pydio

Create the pydio database:

# mysql -u root -p
create database pydio;

Create a database user for Pydio to use and grant it all access to the pydio database:

create user 'webuser'@'localhost' identified by 'USE A REALLY LONG AND STRONG PASSWORD';
GRANT ALL on pydio.* to 'webuser'@'localhost' identified by 'USE A REALLY LONG AND STRONG PASSWORD';

Final configuration:

To finish configuration, using a browser visit https://[URL of Server]/pydio and follow the prompts.  Keep in mind the names you used in the steps above for the Pydio database and the Pydio database user, you will need them for configuration.

Marquee Letters and a 555

I actually made this a while ago, but now I finally have some time to post about it.  This whole endeavor started with my wife picking up a set of marquee letters on clearance.  They are basically letters made out of white plastic with LEDs on them.  Construction wise, they are “OK”, the plastic is sturdy enough and the LEDs are bright.  But I was disappointed because the lights did nothing special, they just powered on.

I took a look at my parts drawer to see what I had available to make something more interesting out of these marquee letters.  There were a couple of microcontrollers, some decade counters, resistors, capacitors and quite a few 555 timers (I must have picked up a bunch on clearance somewhere, because I have a lot of them).  Initially I though of using one of the microcontrollers to animate the lights, then I came to my senses.  The 555 timer and a decade counter are the right tools for this job, no need to whip out a microcontroller.

The circuit was simple enough (you can search Google for LED chasers using 555 and pick one) .  I had no issues putting it together and it makes for a good simple light show.  Now off it goes into our son’s room to eat away batteries and amuse him. See video below.

play-sharp-fill

Building FreeCAD on Debian Stretch

This Howto is based on the instructions from FreeCad’s web site

Get the source from github with:

$ git clone https://github.com/FreeCAD/FreeCAD.git free-cad-code

Install all dependencies:

# apt install build-essential cmake python python-matplotlib libtool libcoin80-dev
# apt install libsoqt4-dev libxerces-c-dev libboost-dev libboost-filesystem-dev
# apt install libboost-regex-dev libboost-program-options-dev libboost-signals-dev
# apt install libboost-thread-dev libboost-python-dev libqt4-dev libqt4-opengl-dev
# apt install qt4-dev-tools python-dev python-pyside pyside-tools libeigen3-dev
# apt install libqtwebkit-dev libshiboken-dev libpyside-dev libode-dev swig
# apt install libzipios++-dev libfreetype6 libfreetype6-dev liboce-foundation-dev
# apt install liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev
# apt install libsimage-dev checkinstall python-pivy python-qt4 doxygen libspnav-dev oce-draw
# apt install liboce-foundation-dev liboce-foundation10 liboce-modeling-dev liboce-modeling10
# apt install liboce-ocaf-dev liboce-ocaf-lite-dev liboce-ocaf-lite10 liboce-ocaf10 liboce-visualization-dev
# apt install liboce-visualization10 libmedc-dev libvtk6-dev libproj-dev checkinstall libsimage-dev

On your home directory create a build directory:

$ mkdir freecad-build

To build frecad source code:

$ cd freecad-build
$ cmake ../[LOCATION_OF_SOURCE]/free-cad-code
$ make -j8

To run it go to freecad-build/bin and execute FreeCAD:

$ cd ~/freecad-build/bin
$ ./FreeCAD

Building aircrack-ng on Debian Stretch from source

In order to build aircrack-ng from source you need the following dependencies:

# apt install pkg-config build-essential libssl-dev subversion git checkinstall
# apt install libgcrypt20-dev
# apt install sqlite3-pcre libsqlite3-dev libpcre3-dev
# apt install ethtool rfkill
# apt install libnl-3-dev libnl-genl-3-dev

Get the source with:
$ svn co http://svn.aircrack-ng.org/trunk aircrack-ng

Start the build with:
$ make sqlite=true pcre=true gcrypt=true

After a successful build, install with:
# checkinstall —fstrans=no

To remove use aircrack-ng:
# dpkg -r aircrack

To update airodump OUI file:

# airodump-ng-oui-update

Pydio 7 with PHP7 and SSL on Debian Jessie

Add the dotdeb repository to get latest PHP 7.

# wget -O- https://www.dotdeb.org/dotdeb.gpg | apt-key add -

Create /etc/apt/sources.list.d/dotdeb.list and add the following:

deb http://packages.dotdeb.org jessie all

Once that is done run the following commands:

# apt-get update
# apt install mysql-server php7.0 php7.0-fpm php7.0-mysql php7.0-curl php7.0-json php7.0-gd php7.0-intl php7.0-mbstring php7.0-xml php7.0-zip php7.0-exif php7.0-apcu
apt-get install libapache2-mod-php

Disable apache support for php5:
# a2dismod php5

Enable apache support for php7:

# a2enmod php7.0

Add the Pydio repository.

Create /etc/apt/sources.list.d/pydio.list and add the following:

# Pydio Community repositories
deb https://download.pydio.com/pub/linux/debian/ jessie-backports main

then:

# wget -qO - https://download.pydio.com/pub/linux/debian/key/pubkey | apt-key add -

# apt-get install apt-transport-https
# apt-get update

# apt-get install pydio
# apt-get install pydio-all

In /etc/php/7.0/apache2/php.ini change:

output_buffering = 4096

to:

output_buffering = off

Create self-signed certificates for Pydio over ssl

# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/pydio-selfsigned.key -out /etc/ssl/certs/pydio-selfsigned.crt
# openssl x509 -in /etc/ssl/certs/pydio-selfsigned.crt -out /etc/ssl/certs/pydio-selfsigned.pem -outform PEM

Enable ssl on apache:

# a2enmod ssl

In the /etc/apalche2/sites-enabled directory:

# rm 000-default.conf
# ln -s ../sites-available/default-ssl.conf default-ssl.conf

In default-ssl.conf change the follwing line from:

SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem

To:

SSLCertificateFile /etc/ssl/certs/pydio-selfsigned.pem

Also change the following line from:

SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

To:

SSLCertificateKeyFile /etc/ssl/private/pydio-selfsigned.key

Restart apache and pydio

Running multiple SSL sites on one IP with NGINX

This how-to will step you through the process needed to be able to run two different SSL sites (completely different URLs) on the same IP (same NGINX server too)

Let’s say you have own the domains www.example1.com and www.example2.org and that you wish to host both sites on the same server with one IP.  Let’s also say you wish to make it so that that both sites are SSL enabled (https).  Finally let’s assume that you have already secured proper SSL certificates for each domain.

The first step should be to ensure that we have the SSL certificates in a good location for NGINX to be able to reach them.  My personal preference isto store the certificates in /etc/nginx/ssl directory, usually in a directory named after the URL for the certificate.  Using the example names from above, we need to create two directories in /etc/nginx/ssl.  Something like the following:
# cd /etc/nginx/ssl
# mkdir www.example1.com
# mkdir www.example2.org

Now copy the certificates to their corresponding directories under /etc/nginx/ssl.

The next step is to create a configuration file for the first domain in /etc/nginx/sites-available directory. Let’s call the configuration file SSL-example1-com, its contents should be:

server {

listen 443;
server_name www.example1.com;

root /usr/share/nginx/www1;
index index.html index.htm;

ssl on;
ssl_certificate /etc/nginx/ssl/www.example1.com/cert_for_example1_com-server.crt;
ssl_certificate_key /etc/nginx/ssl/www.example.com/key_for_example_com1_server.key;
}

Notice that server_name is using the example1.com fully qualified domain name and that
the certificate and key correspond to the example1.com fully qualified domain name.

Now we create the configuration for the second site.  Lets use SSL-example2-org as the name and include the following as content:

server {

listen 443;
server_name www.example2.org;

root /usr/share/nginx/www2;
index index.html index.htm;

ssl on;
ssl_certificate /etc/nginx/ssl/www.example2.org/cert_for_example2-org-server.crt;
ssl_certificate_key /etc/nginx/ssl/www.example2.org/key_for_example2_server_org.key;
}

Notice that server_name is using the example2.org fully qualified domain name and that
the certificate and key correspond to the example2.org fully qualified domain name.

Now create links to these configuration files in etc/nginx/sites-enabled:

# ln -s ../sites-available/SSL-example1-com 001-example-com
# ln -s ../sites-available/SSL-example2-org 002-example-org

Finally restart NGINX

Verified by ExactMetrics
Verified by MonsterInsights