PPTPD on Ubuntu

May 12th, 2013 No comments

Install pptpd:

apt-get install pptpd ufw

Enable ports in ufw:

ufw allow 22
ufw allow 1723
ufw enable

You might also want to enable ports of your other services. (http….)

Add a virtual network interface:

vim /etc/network/interfaces

Sample File:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address 10.0.0.10
  netmask 255.255.255.192
  gateway 10.0.0.129

# virtual interfaces

auto eth0:0
 iface eth0:0 inet static
  address 192.168.89.1
  netmask 255.255.255.0
  gateway 10.0.0.10
  dns-nameservers 10.0.0.12

Add your dns server to:

vim /etc/ppp/pptpd-options

Uncomment ms-dns and add your dns servers, this sample uses the public google dns servers:

ms-dns 8.8.8.8
ms-dns 8.8.4.4

Configure your vpn ip range:

vim /etc/pptpd.conf

Add the following to the end of the file:

localip 192.168.89.1
remoteip 192.168.89.2-20

Add some user account for the vpn server:

vim /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
user            pptpd   my_password             *

Uncomment the following lines in:

vim /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

In:

vim /etc/default/ufw

Change the following line from:

DEFAULT_FORWARD_POLICY="DROP"

to:

DEFAULT_FORWARD_POLICY="ACCEPT"

In the following file:

vim /etc/ufw/before.rules

Add before the filter section:

# nat Table rules
*nat
 :P OSTROUTING ACCEPT [0:0]
# Allow forward traffic from eth0:0 to eth0
-A POSTROUTING -s 192.168.88.0/24 -o eth0 -j MASQUERADE

# dont delete the COMMIT line or these nat table rules wont be processed
COMMIT

Reboot to enable the new settings.

Categories: Ubuntu, Web server Tags:

Installing node.js on Ubuntu 12.04

October 21st, 2012 No comments

Yesterday I wanted finally to get my hands on node.js and I did some research about how to install it best on a Ubuntu server. I found the following very helpful post that actually got me started.

My first step was to create a new dedicated user for node.js.

useradd -g ftpuser -d /var/www/node -s /bin/ftp -m node
chown node.www-data /var/www/node
chmod 750 /var/www/node
mkdir /var/www/node/conf
mkdir -p /var/www/node/domain/{cgi-bin,exec,html,log,session,temp}
chmod 770 /var/www/node/domain/temp
chmod 777 /var/www/node/domain/session
chmod 700 /var/www/node/domain/exec
chown -R node.ftpuser /var/www/node/*
rm -rf /var/www/node/.b*
rm -rf /var/www/node/.p*

This follows the pattern for user creation established in previous posts.

After this I follow the steps described in the post mentioned above.

sudo apt-get update
sudo apt-get install build-essential -y

sudo apt-get install git -y

sudo apt-get install python libssl-dev -y

Now I install node into the home of the new user that we created before.

sudo su -s /bin/bash node
mkdir -p /var/www/node/local/src
cd /var/www/node/local/src
git clone git://github.com/joyent/node.git
cd node
sudo git checkout v0.8.12
./configure --prefix=/var/www/node/local
make
make install

Now that every thing is locally installed we make the binaries accessible.

echo 'PATH=$PATH:$HOME/local/bin' >> $HOME/.bashrc
source ~/.bashrc
Categories: git, Linux, Ubuntu Tags:

Create a custom linux-source-2.6.31 ubuntu 9.10 kernel

November 10th, 2009 2 comments

This is a quick and very dirty how to about building a custom kernel for ubuntu 9.10, it’s based on this how to.

First we make sure our system is up to date:

sudo apt-get update
sudo apt-get upgrade

Now we install all needed packages:

sudo apt-get install linux-source-2.6.31 kernel-package fakeroot kernel-wedge build-essential \
makedumpfile build-dep linux linux libncurses5 libncurses5-dev linux-headers-generic

We unpack the source files to a custom directory in our home directory:

mkdir ~/src
cd ~/src
tar xjvf /usr/src/linux-source-2.6.31.tar.bz2
cd linux-source-2.6.31

We want to reuse the existing config:

cp -vi /boot/config-`uname -r` .config

Now you can customize the kernel:

make menuconfig

Then we can build it:

make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=custom-1 kernel-image kernel-headers

Ensure that frame buffer drivers are loaded:

echo vesafb | sudo tee -a /etc/initramfs-tools/modules
echo fbcon | sudo tee -a /etc/initramfs-tools/modules

Install the new packages:

dpkg -i linux-image-2.6.31.4custom-1_2.6.31.4custom-1-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.31.4custom-1_2.6.31.4custom-1-10.00.Custom_i386.deb
Categories: Web server Tags:

Managing apache users on Ubuntu via shell scripts

October 17th, 2009 No comments

I created some shell scripts to add and delete apache web users. You can download them via this post.

This script creates users and requires this webserver setup:
addweb

You also need the following default files:
default-vhost
default-php5-fcgi-starte
php.ini

There is another script to delete users from apache and the system:
dellweb

Installation:

All files have to be saved in the same directory, to run the .sh files they must have proper rights:

chmod +x addweb.sh
chmod +x dellweb.sh

To run the scrips type:

 
sudo ./addweb username
sudo ./dellweb username

Then follow the dialog. On request the script could be writen dialog free as well.

Categories: Web server Tags:

Install postgresql on Ubuntu with php5

October 16th, 2009 No comments

In this installation we integrate postgresql into this apache installation.

First we refresh our package management and our packages:

apt-get update
apt-get upgrade

Then we have to install the basic packages:

apt-get install postgresql postgresql-server-dev-8.3 php5-pgsql

Now we have to do the basic setup of the postgresql server:

sudo -u postgres psql template1

Now you can define a passwort for the postgres user:

\password postgres

To leave the prompt enter:

\q
Categories: PHP, postgresql, Ubuntu Tags:

Install phpPgAdmin on Ubuntu

October 16th, 2009 No comments

In order to use this how to you have to install apache first following this how to. Also postgresql has to be installed, therefore you can follow this how to.

First we create a new user:

useradd -g ftpuser -d /var/www/pga -s /bin/ftp -m pga
chown pga.www-data /var/www/pga
chmod 750 /var/www/pga
mkdir /var/www/pga/conf
mkdir -p /var/www/pga/domain/{cgi-bin,exec,html,log,session,temp}
chmod 770 /var/www/pga/domain/temp
chmod 777 /var/www/pga/domain/session
chmod 700 /var/www/pga/domain/exec
chown -R pga.ftpuser /var/www/pga/*
rm -rf /var/www/pga/.b*
rm -rf /var/www/pga/.p*

Then we create a vHost for the new pga user:

cd /etc/apache2/sites-available/
vim pga

We add the following configuration:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        SuexecUserGroup pga ftpuser
        ServerName www.domain.tld
        ServerAlias more.domains.tld
        DocumentRoot /var/www/pga/domain/html
        DirectoryIndex index.php index.html index.htm

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory />
                Order Deny,Allow
                Deny from All
        </Directory>

        <Directory /var/www/pga/domain/html>
                FCGIWrapper /var/www/php-fcgid-scripts/pga/php-fcgid-starter .php
                Options +ExecCGI
                order allow,deny
                allow from all
        </Directory>
        ErrorLog /var/www/pga/domain/log/apache_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/www/pga/domain/log/apache_access.log combined
        ServerSignature On
</VirtualHost>

Now we create the fcgi configuration:

cd /var/www/php-fcgid-scripts/
mkdir pga
cd pga
touch php-fcgid-starter
chmod +x php-fcgid-starter
vim php-fcgid-starter

Now we add the configuration:

#!/bin/sh
PHPRC="/var/www/pga/conf"
export PHPRC
PHP_FCGI_CHILDREN=15
export PHP_FCGI_CHILDREN
exec /usr/bin/php5-cgi

We configure the proper rights:

chown -R pga.ftpuser /var/www/php-fcgid-scripts/pga
chmod 755 /var/www/php-fcgi-scripts/pga/php-fcgi-starter
chattr -V +i /var/www/php-fcgid-scripts/pga/php-fcgid-starter

We create a php.ini file for this vHost:

cd /var/www/pga/conf
wget http://www.naumann.cc/wp-content/uploads/2009/10/php.ini
chown root.root php.ini

Now we download the pgaPgAdmin interface:

cd /var/www/pga/domain/
su -m pga
wget http://downloads.sourceforge.net/project/phppgadmin/phpPgAdmin%20%5Bstable%5D/phpPgAdmin-4.2.2/phpPgAdmin-4.2.2.tar.bz2?use_mirror=mesh
tar xjvf phpPgAdmin-4.2.2.tar.bz2

Then we copy all files into the html directory:

mv phpPgAdmin-4.2.2/* html/

Now we have to configure the postgresql server for the usage of phpPgAdmin:

vim /etc/postgresql/8.3/main/postgresql.conf

Ennable the following line:

listen_addresses = 'localhost'

Create a new user for phpPgAdmin:

sudo -u postgres createuser -D -A -P myuser
sudo -u postgres createdb -O myuser mydb

Change the authentication settings in the following file to allow access via phpPgAdmin via this user:

vim /etc/postgresql/8.3/main/pg_hba.conf

Add this line:

local   all         myuser                             md5

before:

local   all         all                               ident sameuser
Categories: apache, PHP, postgresql, Ubuntu Tags:

Install a dyndns client on Ubuntu

October 16th, 2009 No comments

This how to will guide you through the process of installing a dynamic dns service client on Ubuntu.

First we update our package manager:

apt-get update
apt-get upgrade

Now that we have a current system we can install the new package:

apt-get install ddclient

Select your dyndns provider from the list, for me it’s www.dyndns.com.

Enter the domain name that should be updated into the following field.

Enter your user name and password.

In the next dialog you have to enter the network device whos ip where the domain name should be resolved to.

For me this is eth0.

You can change the settings also via the config file:

vim /etc/ddclient.conf

My file looks as follows:

# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf

pid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=eth0
server=members.dyndns.org
login=username
password='password'
host.dyndns.biz
Categories: dyndns, Ubuntu Tags:

IMAP mail account migration

June 29th, 2009 No comments

I moved my email account to FastMail.fm and had to migrate an imap mailbox via my ubuntu desktop. If you want to join them feel free to use my link with referal code :) FastMail.fm

First we have to install the imapsync package:

sudo apt-get install imapsync

Then we have to trigger the migration:

imapsync --syncinternaldates \
  --host1 mail.source.tld --authmech1 LOGIN --user1 user@domain.tld --password1 secret \
  --host2 mail.target.tld --authmech2 LOGIN --user2 user@domain.tld --password2 secret

Now drink a coffee :D , because this can take a while.

Categories: IMAP, Linux, Mail, Ubuntu Tags:

Syncronize time on ubuntu

June 18th, 2009 No comments

This how to is based on the ubuntu documentation. First we have to add the basic packages:

sudo apt-get install ntp ntpdate

Than we have to do some basic configuration:

echo "ntpdate ntp.ubuntu.com pool.ntp.org " >> /etc/cron.daily/ntpdate
sudo chmod 755 /etc/cron.daily/ntpdate
echo "server ntp.ubuntu.com" >> /etc/ntp.conf
echo "server pool.ntp.org" >> /etc/ntp.conf

Have a look at this page for more ntp Servers.

I had to change my timezone as well, this can be done by changing a symbolic link:

ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Just replace Europe/Berlin by your timezone. You can find more information about changing timezones here.

Categories: Linux, Ubuntu Tags:

Adding madwifi support to easy peasy

June 17th, 2009 No comments

As descibed here we have to install the kernel headers first:

sudo apt-get install build-essential linux-headers-$(uname -r) subversion

Now we can add the madwifi drivers for the wlan chipset:

cd /usr/local/src
svn checkout http://madwifi-project.org/svn/madwifi/trunk madwifi
cd madwifi
make
sudo make install
sudo modprobe ath_pci

You can find some additional Information of putting madwifi into a kernel at this page. (German)

We have to do some additional configuration first we have to add the module to /etc/modules:

echo "ath_pci" >> /etc/modules

I added some scripts following the howto.

Categories: easy peasy, Linux, Ubuntu Tags: