How to install FTP Server (pure-ftp) on FreeBSD 10.1

This is 3rd post from virtual user hosting with FreeBSD 10 series. First two are located here :

  1. How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : Part 1 – Setup
  2. How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : Part 2 – TLS & Unix Auth

I restart the process using latest FreeBSD version at the moment : FreeBSD 10.1 using custom iso.

Some highlight from FreeBSD 10.1-RELEASE announcement :

  • The new console driver, vt(4), has been added.
  • Support for FreeBSD/i386 guests has been added to bhyve(4).
  • The bhyve(4) hypervisor now supports booting from a zfs(8) filesystem.
  • Support for SMP was added to the armv6 kernels and enabled by default in the configuration files for all platforms that contain multi-core CPUs.
  • Initial support for UEFI boot has been added for the FreeBSD/amd64 architecture.
  • Support has been added to cache geli(8) passphrases during system boot.
  • Support for the UDP-Lite protocol (RFC 3828) has been added to the IPv4 and IPv6 stacks.
  • The new filesystem automount facility, autofs(5), has been added.
  • The sshd(8) rc.d(8) startup script now generates ED25519 sshd(8) host keys if keys do not already exist when ssh_keygen_alg() is invoked.
  • OpenSSH has been updated to version 6.6p1.
  • The nc(1) utility has been updated to match the version in OpenBSD 5.5.
  • Sendmail has been updated to 8.14.9.
  • The unbound(8) caching resolver and ldns have been updated to version 1.4.22.
  • OpenPAM has been updated to Ourouparia (20140912).
  • OpenSSL has been updated to version 1.0.1j.
  • The pkg(8) package management utility has been updated to version 1.3.8.

Back to process :-)

# uname -rsv
FreeBSD 10.1-RELEASE FreeBSD 10.1-RELEASE #0 r274401: Tue Nov 11 22:51:51 UTC 2014     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC

Update Package

# pkg update
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
………………………………..

…………………………………………

…………………………………………………..
Updating FreeBSD repository catalogue…
Fetching meta.txz: 100%   944 B   0.9k/s    00:01
Fetching digests.txz: 100%    2 MB 108.8k/s    00:19
Fetching packagesite.txz: 100%    5 MB  95.6k/s    00:56
Processing new repository entries: 100%
FreeBSD repository update completed. 23787 packages processed:
0 updated, 0 removed and 23787 added.

Install Ports

# portsnap fetch

# portsnap extract

# cd /usr/ports/ftp/pure-ftpd/

pure-ftpd-freebsd options

To reduce dependency compile process (download and install for each dependency), I ask for pkg help :

# pkg install dialog4ports mysql55-client perl5

Resume make install process of pure-ftp ports.

# make install

Check everything

# pkg info
dialog4ports-0.1.5_2           Console Interface to configure ports
mysql55-client-5.5.40          Multithreaded SQL database (client)
perl5-5.16.3_11                Practical Extraction and Report Language
pkg-1.3.8_3                    Package manager
pure-ftpd-1.0.36_3             Small, easy to set up, fast, and secure FTP server

Enable pureftp

#echo 'pureftpd_enable=YES' >>/etc/rc.conf

Since I want MySQL support for pure-ftp then I install MySQL server.

# pkg install mysql55-server

Enable MySQL server to start automatically after server reboot.

# echo 'mysql_enable=YES' >> /etc/rc.conf

Start MySQL server

# /usr/local/etc/rc.d/mysql-server start

According to pure-ftpd manual (mysql section).

Table structure for hold virtual user as follows :

CREATE TABLE users (
  User VARCHAR(16) BINARY NOT NULL,
  Password VARCHAR(64) BINARY NOT NULL,
  Uid INT(11) NOT NULL default '-1',
  Gid INT(11) NOT NULL default '-1',
  Dir VARCHAR(128) BINARY NOT NULL,
  PRIMARY KEY  (User)
);

Lets create that table.

# cat /etc/master.passwd | grep mysql
mysql:*:88:88::0:0:MySQL Daemon:/var/db/mysql:/usr/sbin/nologin

In my opinion Uid and Gid is 88. But as pure-ftpd manual said about 1000. I use it.

Ok, lets log in to MySQL database and insert user :

# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.40 Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> create database ftp;
Query OK, 1 row affected (0.01 sec)

mysql> use ftp;
Database changed
mysql> CREATE TABLE users (
->   User VARCHAR(16) BINARY NOT NULL,
->   Password VARCHAR(64) BINARY NOT NULL,
->   Uid INT(11) NOT NULL default ‘-1’,
->   Gid INT(11) NOT NULL default ‘-1′,
->   Dir VARCHAR(128) BINARY NOT NULL,
->   PRIMARY KEY  (User)
-> );
Query OK, 0 rows affected (0.02 sec)

mysql> insert into users set User=’alamsyah’,Password=md5(‘123456′), Uid=1000,Gid=1000,Dir=’/home/ftpdata/alamsyah’;
Query OK, 1 row affected (0.00 sec)

mysql>

The command above work : log in to database, create database named ‘ftp’ . Choose database ‘ftp’. Create table named ‘users’ with its structure and insert data into the table.

At this stage pure-ftpd is running, MySQL server also running. Example user also take place.

Configuration

Create directory

# mkdir -p /home/ftpdata

To be able to read MySQL data, purfe-ftpd.conf need to know that.

# cd /usr/local/etc/

# mv pure-ftpd.conf.sample pure-ftpd.conf

# ee pure-ftpd.conf

remove # sign in front of MySQLConfigFile

from

# MySQL configuration file (see README.MySQL)

# MySQLConfigFile               /etc/pureftpd-mysql.conf

# CreateHomeDir               yes

into

# MySQL configuration file (see README.MySQL)

MySQLConfigFile               /usr/local/etc/pureftpd-mysql.conf

CreateHomeDir               yes

save the file.

Next step is create mysql configuration file and fill the data.

# mv pureftpd-mysql.conf.sample pureftpd-mysql.conf

# ee pureftpd-mysql.conf

The file content is well explained.

From these lines :

MYSQLUser       root

# Mandatory : user password. You must have a password.

MYSQLPassword   rootpw

# Mandatory : database to open.

MYSQLDatabase   pureftpd

# Mandatory : how passwords are stored
# Valid values are : “cleartext”, “crypt”, “sha1”, “md5” and “password”
# (“password” = MySQL password() function)
# You can also use “any” to try “crypt”, “sha1”, “md5” *and* “password”

MYSQLCrypt      cleartext

You need to change a few lines :

MysqlUser : root -> keep this as is.

MysqlPassword : not set yet, change to anything designed. For example ‘123456secret’.

MysqlDatabase : ftp (this database already created in above step).

MySQLCrypt : md5 (user alam in previous step use md5)

The rest is not changed.

save the file.

Next step is change mysql password for user root to : 123456secret.

# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.40 Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> update user set password=password(‘123456secret’) where user=’root’;
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

Test it

# ftp localhost
Trying 127.0.0.1:21 …
Connected to localhost.
220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
220-You are user number 1 of 50 allowed.
220-Local time is now 13:42. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (localhost:alam): alamsyah
331 User alamsyah OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
229 Extended Passive mode OK (|||46398|)
150 Accepted data connection
drwxr-xr-x    2 1000       1000              512 Nov 22 13:42 .
drwxr-xr-x    2 1000       1000              512 Nov 22 13:42 ..
226-Options: -a -l
226 2 matches total
ftp>

If anything is not right then you may refer to log

# tail -f /var/log/messages

If you need to enable TLS you refer to 2nd post.

See you next time!

iphone 6 case collection

My friend show me his new phone. Its iphone 6 unlocked with dimension 4.7 inch and he seem very proud. I just a bit surprise since I knew he is big fan of Android and have many gadget related such Galaxy note and samsung galaxy tab. He told me that he want to impress someone.

He want me to help him for collecting as many iphone6 case design or ready to buy iphone 6 case since he want to make surprise for someone. I agree to and try to collect it in general form. Perhaps I also need it in the future since my Lenovo S800 seem to not working well now.

I don’t know about someone that my friend talking about. His girlfriend or his family member or his working partners so I try to list my best guess. Too many case is never hurt :-)

4 things that could potentially harm your iphone 6 :

1. Dimension; old iphone version is never went to far for dimension. Newest iphone 6 plus reach 5 inch dimension that might lead to few problems. Bigger dimension mean bigger pocket and flexible storage,restrict movement and mobility. Potential harm that might occur; drop and surface scratch if other strong material exist in your pocket.

2. Environment, interactions with the environment such as dust or water that might happen like sudden exposure to water such as rain or splashing water from a party that is not planned to be anticipated from the beginning.

3. Drop, dropping a phone is another human mistake. We never unintended but often occur. Drop into solid ground often result to visual damage and drop into water lead to total damage.

4. Scratch, many factor that lead to scratch to your iphone. Choose wrong surface cover or case material.

Those potential problems are my basic assumption for creating this list, to get exact product that fit your expectation need more review since every one has their own pass list. I do my best to gather helpful link for you before make final decision.

Protection based case for Iphone 6

Waterproof

My friend like to visit beach, swimming pool and related water source. I think best option to protect his iphone 6 from water is waterproof iphone 6 case. A few things to consider for this kind of case are :

  • Headphone, make sure to pay attention for things that able to keep you headphone. Did the design also came with keeper to make headphone stay attached or you have to keep it manually.
  • Touch id, make sure to read other user experience. Some case is working well with water but sacrifice functionality such touch id, not responsive touch screen and force you to press hard.
  • Material, plastic is great but other manufacturer use Aluminum.
  • Ability to access all phone functionality.
  • Proper series, brand like otterbox have a few series. Choose the series that many people use.

Shockproof

The natural location of phone is pocket for many case. At least once in lifetime every person drops their phone. Shockproof protection is basic need for me. Apple might change the material they choose for iphone 6 but customer can prevent it from unknown disaster after unexpected drops. Urban Armor Gear is great product. They create sleek interface that warranted for 12 month and received 4++ rating in average from Amazon customer.

All in one protection iphone 6 case

Some manufacturer also develop many protection for their case. Waterproof, water resist, dust proof, shockproof in one product. Many of them under $40 with the range of $15-$36. I’m practical person, I tend to seek other experience. When I have to choose for example waterproof case for iphone 6 then I prefer to use 4++ rating and if possible rated more than 100 person.

Branded iphone 6 case

Griffin survivor  iphone 6 case

During my search, I found about brand that seem to focus on meet or exceed standard of US Department of Defense MIL-STD-810G. Passion is great when it has target. I think other brand also have their own standard but If you can deliver military standard with great price then you are in good path. Griffin also know as brand that often released earlier then their competitor.

Otterbox

Another famous brand that get rating 4++ in average for most of their product series. Temporarily out of stock status in their storefront for some series also make curious to read the reviews. Specially when I see more than 600 users give their voice.

Custom iphone 6 case

Custom iphone 6 case often designed for specific purpose like gift. A few manufactures provide many design submitted by ordinary person that sometime has deep expression. Ability to give small but meaningful touch often work well many situation like; personal name printed in your iphone 6 case.

As the technology always changing I’ll update this post if I found something new that appropriate. More with customer review since their voice is loud and reflect the product in real world use.

How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : Part 2 – TLS & Unix Auth

In 1st part of this post I have very general setting for pure-ftp configured. In this post we’ll explore about testing functionality of this ftp server using simple auth plus how configure TLS section.

To test the server I need to add user. I used to use sysinstall for this purpose but since sysinstall no longer available on FreeBSD then I use bsdconfig.

Introduce bsdconfig

From bsconfig manual :

bsdconfig is used to set up many system configuration settings, both for
new systems, as well as changing configuration settings of existing systems.

bsdconfig optionally takes    a command as an    argument.  If invoked with no arguments,
it will bring up an interactive    menu listing the available modules.

I like gui version so I type bsdconfig or you can use full path : /usr/sbin/bsdconfig

If not available you can install it.

From ports

# /usr/ports/sysutils/bsdconfig && make install

From pkg

# pkg install bsdconfig

For pure-ftp purpose I need bsdconfig for add new user :

#bsdconfig

Choose “Login/Group Management”

bsdconfig as sysinstall replacement

Continue reading

How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : Part 1 – Setup

My friend who work as R & D for small company told me about new policy from their management. Every one must backup their work once in a week and that backup also include internet backup. Such solution like dropbox is not allowed since their management a bit worry about control. What if they need to conduct audit of their backup or see bad pattern from there. One of management person told him about FTP as alternative that located in vps. Since my friend never use ftp before he ask me to create demo for him. Not a big deal since I ever work with such solution, utilize pureftp as ftp server and mysql as database server where they store user information like directory, password etc. In this post I’ll use FreeBSD 10 as operating system.

Preparation

I use Vultr as vps provider. In reality I should use their ‘strorage series‘ that utilize sata storage. But for demo purpose and speed access. I choose performance series.

How to install virtual Ftp hosting with PureFTP on FreeBSD 10 : choose storage series

Operating system

FreeBSD 10 x64 with latest patch (automatic freebsd-update using posti install) from vultr.

Continue reading

DragonFlyBSD pkg : initial impression

After use pkg in FreeBSD 10 and very satisfied with the result I feel curious about its brother, DragonFlyBSD.

I install DragonFlyBSD 3.8.2 using 32 bit inside my virtualbox ( I think its same if I run with vps that provide custom iso like vultr).

After configure ssh server for network access, I start test pkg command :

$ ssh alam@192.168.1.201
alam@192.168.1.201’s password:
Last login: Tue Oct 21 08:17:01 2014
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.

DragonFly v3.8.2-RELEASE (GENERIC) #7: Thu Aug 14 21:26:32 PDT 2014

Welcome to DragonFly!

To erase a line you’ve written at the command prompt, use “Ctrl-U”.
— Dru <genesis@istar.ca>
> su
dflybsd#

# pkg update
Updating repository catalogue
pkg: http://mirror-master.dragonflybsd.org/dports/dragonfly:3.8:x86:32/LATEST/meta.txz: Not Found
pkg: repository Avalon has no meta file, using default settings
Fetching digests.txz: 100% of 977 KB
Fetching packagesite.txz: 100% of 4 MB

Adding new entries: 100%
Incremental update completed, 20921 packages processed:
0 packages updated, 0 removed and 20921 added.
dflybsd# pkg info

bind98-9.8.7P1_5               BIND DNS suite with updated DNSSEC and DNS64
ca_root_nss-3.16.1             The root certificate bundle from the Mozilla Project
cdrtools-3.00_2                CD/DVD/BluRay and ISO-9660 image creation and extraction tools
curl-7.37.1_2                  Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
cvsps-2.1_1                    Create patchset information from CVS
expat-2.1.0_1                  XML 1.0 parser written in C
gettext-0.18.3.1_1             GNU gettext package
git-2.0.2                      Distributed source code management tool
indexinfo-0.2                  Utility to regenerate the GNU info page index
isc-dhcp42-server-4.2.6_2      The ISC Dynamic Host Configuration Protocol server
libxml2-2.9.1_1                XML parser library for GNOME
openssl-1.0.1_13               SSL and crypto library
pkg-1.3.6                      Package manager

#

Preinstalled package after I type pkg update is more than FreeBSD offer but I like it, I have git, curl and bind out of box :-)

See what version of compiler DragonFlyBSD use

# cc -v
Using built-in specs.
COLLECT_GCC=/usr/libexec/gcc47/cc
Target: i386-pc-dragonflybsd
Configured with: DragonFly/i386 system compiler (c, c++, objc, LTO)
Thread model: posix
gcc version 4.7.3 [DragonFly] Release/2013-04-11

Try find wordpress

# pkg search wordpress

de-wordpress-3.8
ja-wordpress-3.8.1
p5-WordPress-XMLRPC-1.23
ru-wordpress-3.8.1
wordpress-3.8.1,1
zh-wordpress-zh_CN-3.8.1
zh-wordpress-zh_TW-3.8.1

Looks like the version is bit out date but not big problem for me as wordpress provide easy upgrade procedure.

Good news for me is PHP also available in 5.2 version.

Try install it via pkg

# pkg install php52
Updating repository catalogue
pkg: http://mirror-master.dragonflybsd.org/dports/dragonfly:3.8:x86:32/LATEST/meta.txz: Not Found
pkg: repository Avalon has no meta file, using default settings
Avalon repository is up-to-date
All repositories are up-to-date
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
php52: 5.2.17_15

The process will require 7 MB more space
1 MB to be downloaded

Proceed with this action [y/N]: y
Fetching php52-5.2.17_15.txz: 100% of 1 MB
Checking integrity… done (0 conflicting)
[1/1] Installing php52-5.2.17_15: 100%

I don’t understand about error message above (Avalon has no meta file) so I ignore it :-)

Looks like I love DragonFlyBSD too. Same pkg and no hard learning curve :-)