Feeds:
Posts
Comments

Archive for October 18th, 2007

FTP Server

What is FTP?

FTP (File Transfer Protocol) is a program to exchange files between two computers or to other computers in a local network or over inter networks (internet). May be you don’t know that you’ve already used it before when you download something from the internet. Most often, a computer with a FTP address is dedicated to receive a FTP connection.

What is ftp sites?

Ftp site is the like old Filling cabinets where you put your datas in it. Organized and labeled so it will easier next time you or any one who need the files can take it back next time.

That concept is applied in ftp sites. You can take any files that you want to download based access level provided. The Administrator can set which files to keep locked and which open to public.

What is ftp Server?

Ftp server is a machine that serves the authorized users to get the requested files. The FTP file sharing protocol is an old protocol which was created when internet was still a secure place. That’s why the default FTP protocol is not that secure. Mean that your username and password for login are transmitted in plain text, well… which is not secure for sure.

 

There are several configurations that you can set for your proftpd server.

  • as chrooted at /home directory

  • as anonymous proftpd user to read only

  • as anonymous proftpd user to read/write

  • as anonymous proftpd user to directory outsite /home/ftp

 

In this article, I want to show you how you can create a ftp server in a short time. In this practice, I use ‘proftpd’ as our ftp server. The file is not too big and it’s not difficult to install.

 

Step 1. Download and Installing ‘proftpd’ program for FTP server

taufanlubis@zyrex:~$ sudo apt-get install proftpd

Reading package lists… Done

Building dependency tree

Reading state information… Done

Suggested packages:

proftpd-doc

The following NEW packages will be installed:

proftpd

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 784kB of archives.

After unpacking 2331kB of additional disk space will be used.

Get:1 http://archive.ubuntu.com feisty/universe proftpd 1.3.0-21ubuntu1 [784kB]

Fetched 784kB in 14s (54.1kB/s)

Preconfiguring packages …

Selecting previously deselected package proftpd.

(Reading database … 155004 files and directories currently installed.)

Unpacking proftpd (from …/proftpd_1.3.0-21ubuntu1_i386.deb) …

Setting up proftpd (1.3.0-21ubuntu1) …

——— IMPORTANT INFORMATION FOR XINETD USERS ———-

The following line will be added to your /etc/inetd.conf file:

ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/proftpd

 

If you are indeed using xinetd, you will have to convert the

above into /etc/xinetd.conf format, and add it manually. See

/usr/share/doc/xinetd/README.Debian for more information.

———————————————————–

Adding system user `proftpd’ (UID 118) …

Adding new user `proftpd’ (UID 118) with group `nogroup’ …

Not creating home directory `/var/run/proftpd’.

Adding system user `ftp’ (UID 119) …

Adding new user `ftp’ (UID 119) with group `nogroup’ …

Creating home directory `/home/ftp’ …

`/usr/share/proftpd/templates/welcome.msg’ -> `/home/ftp/welcome.msg.proftpd-new’

ProFTPd warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration.

taufanlubis@zyrex:~$

 

Step 2. Test it to run

taufanlubis@zyrex:~$ sudo /etc/init.d/proftpd start

Password:

ProFTPd warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration.

taufanlubis@zyrex:~$

This error occurs because we haven’t set the configuration file yet.

 

Step 3. Create your proftpd directory

For this practice, I create ftp_shared directory at home/ directory.

taufanlubis@zyrex:/home$ sudo mkdir ftp_shared/

Then I create 2 more directories inside ftp_shared directory.

taufanlubis@zyrex:/home$ cd ftp_shared/

taufanlubis@zyrex:/home/ftp_shared$ sudo mkdir download

taufanlubis@zyrex:/home/ftp_shared$ sudo mkdir upload

 

Set security permission

taufanlubis@zyrex:/home/ftp_shared$ cd ..

taufanlubis@zyrex:/home$ sudo chmod 755 ftp_shared/

taufanlubis@zyrex:/home$ cd ftp_shared/

taufanlubis@zyrex:/home/ftp_shared$ sudo chmod 755 download/

taufanlubis@zyrex:/home/ftp_shared$ sudo chmod 777 upload/

taufanlubis@zyrex:/home/ftp_shared$ ls -l

total 8

drwxr-xr-x 2 root root 4096 2007-10-17 19:31 download

drwxrwxrwx 2 root root 4096 2007-10-17 19:31 upload

taufanlubis@zyrex:/home/ftp_shared$

Step 4. Create your proftpd user

Just add a user from ‘Users and Groups’ Ubuntu menu.

System > Administration > Users and Groups then just click Add user.

or you can do this job through linux console

taufanlubis@zyrex:/home$ sudo useradd userftp -p 123456 -d /home/ftp_shared

 

Step 5. Configuring proftpd server

The final preparation is configure your proftpd server.

The proftpd configuration file is located at /etc/proftpd/proftpd.conf.

taufanlubis@zyrex:~$ cd /etc/proftpd/

taufanlubis@zyrex:/etc/proftpd$ ls -l

total 12

-rw-r–r– 1 root root 738 2007-10-08 07:20 modules.conf

-rw-r–r– 1 root root 4491 2007-10-08 07:20 proftpd.conf

taufanlubis@zyrex:/etc/proftpd$

Create a backup file

Always create a back before you change any configuration files.

taufanlubis@zyrex:/etc/proftpd$ sudo cp proftpd.conf proftpd.conf.original

taufanlubis@zyrex:/etc/proftpd$ ls -l

total 20

-rw-r–r– 1 root root 738 2007-10-08 07:20 modules.conf

-rw-r–r– 1 root root 4491 2007-10-08 07:20 proftpd.conf

-rw-r–r– 1 root root 4491 2007-10-09 04:26 proftpd.conf.original

taufanlubis@zyrex:/etc/proftpd$

 

Edit proftpd configuration file

Replace the content with our new configuration data.

taufanlubis@zyrex:/etc/proftpd$ sudo gedit proftpd.conf

Include /etc/proftpd/modules.conf

 

# ———————————————–

UseIPv6 off

ServerName “UbuntuFtp”

ServerType standalone

DeferWelcome on

 

MultilineRFC2228 on

DefaultServer on

ShowSymlinks off

 

TimeoutNoTransfer 600

TimeoutStalled 600

TimeoutIdle 1200

 

DisplayLogin welcome.msg

DisplayFirstChdir .message

ListOptions “-l”

 

RequireValidShell off

Timeoutlogin 20

RootLogin off

DenyFilter \*.*/

 

# ———————————————–

#Port 21 is the standard FTP port, just change

#to another port for security reason

Port 2007

 

MaxInstances 9

User userftp

Group nogroup

Umask 022 022

 

MaxClients 8

MaxClientsPerHost 8

MaxClientsPerUser 8

MaxHostsPerUser 8

 

AllowOverwrite on

PersistentPasswd off

 

UseSendFile off

 

#Display a message after login

AccessGrantMsg “Welcome to Ubuntu ftp Server!!!”

 

ServerIdent on “you’re at home”

DefaultRoot /home/ftp_shared

 

MaxLoginAttempts 5

 

#Create your log file

ExtendedLog /var/log/ftp.log

TransferLog /var/log/proftpd/xferlog

SystemLog /var/log/proftpd/proftpd.log

 

# ———————————————–

<Limit LOGIN>

AllowUser userftp

Deny All

</Limit>

 

<Directory /home/ftp_shared>

Umask 022 022

AllowOverwrite off

<Limit MKD STOR DELE XMKD RNRF RNTO RMD XRMD>

DenyAll

</Limit>

</Directory>

 

<Directory /home/ftp_shared/download/*>

Umask 022 022

AllowOverwrite off

<Limit MKD STOR DELE XMKD RNEF RNTO RMD XRMD>

DenyAll

</Limit>

</Directory>

 

<Directory /home/ftp_shared/upload/>

Umask 022 022

AllowOverwrite on

<Limit READ RMD DELE>

DenyAll

</Limit>

</Directory>

# ———————————————–

Save the edited file and restart the FTP server.

taufanlubis@zyrex:~$ cd /etc/init.d/

taufanlubis@zyrex:/etc/init.d$ sudo ./proftpd start

* Starting ftp server proftpd [ OK ]

 

or

 

taufanlubis@zyrex:~$ sudo /etc/init.d/proftpd start

* Starting ftp server proftpd [ OK ]

taufanlubis@zyrex:~$

 

Now, you have your own ftp server already.
You can test it using FileZilla or Firefox (any web browsers).

Access ftp server using FileZilla
Enter Host: 192.168.0.2 (my ip address), username: userftp, password: 123456, port: 2007

Access ftp using FileZilla

Access ftp server using Firefox

Type: ftp://192.168.0.2:2007 in your firefox Url box.
Enter user name: userftp

Enter password: 123456
Access ftp using Firefox

loginftp2.png

Read Full Post »

Follow

Get every new post delivered to your Inbox.

Join 73 other followers