Rabu, 04 April 2012

KONFIGURASI FTP SERVER DI UBUNTU


Langkah-langkah konfigurasi FTP Server (proftpd) di Ubuntu :
1. Download dan install program proftpd untuk FTP Server.
#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.

Coba jalankan proftpd
.
#/etc/init.d/proftpd start
Password:
ProFTPd warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration.

2. Jika tidak ada repositori lokal, maka bisa dilakukan secara manual yaitu dengan menginstall file-file dependensi yang dibutuhkan. Install program proftpd (proftpd_1.3.0-24ubuntu1_i386.deb).
root@komputer02-desktop:/# dpkg -i proftpd_1.3.0-24ubuntu1_i386.deb
(Reading database ... 89245 files and directories currently installed.)
Preparing to replace proftpd 1.3.0-24ubuntu1 (using proftpd_1.3.0-24ubuntu1_i386.deb) ...
Unpacking replacement proftpd ...
dpkg: dependency problems prevent configuration of proftpd:
 proftpd depends on libmysqlclient15off (>= 5.0.27-1); however:
  Package libmysqlclient15off is not installed.
 proftpd depends on libpq5; however:
  Package libpq5 is not installed.
dpkg: error processing proftpd (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 proftpd

Dari pesan di atas bisa dilihat bahwa instalasi proftpd masih membutuhkan file dependensi: libmysqlclient15off dan libpq5.
Install dulu file dependensi dengan menggunakan perintah: dpkg -i namafile.deb
Jika sudah, coba install lagi proftpd (proftpd_1.3.0-24ubuntu1_i386.deb)
root@komputer02-desktop:/# dpkg -i libmysqlclient15off_5.0.45-1ubuntu3.4_i386.deb
(Reading database ... 89098 files and directories currently installed.)
Preparing to replace libmysqlclient15off 5.0.45-1ubuntu3.4 (using libmysqlclient15off_5.0.45-1ubuntu3.4_i386.deb) ...
Unpacking replacement libmysqlclient15off ...
Setting up libmysqlclient15off (5.0.45-1ubuntu3.4) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place

Begitu juga dengan file libpq5 dilanjutkan dengan install proftpd.
root@komputer02-desktop:/# dpkg -i proftpd_1.3.0-24ubuntu1_i386.deb
(Reading database ... 89098 files and directories currently installed.)
Preparing to replace proftpd 1.3.0-24ubuntu1 (using proftpd_1.3.0-24ubuntu1_i386.deb) ...
Unpacking replacement proftpd ...
Setting up proftpd (1.3.0-24ubuntu1) ...
Adding system user `proftpd' (UID 109) ...
Adding new user `proftpd' (UID 109) with group `nogroup' ...
Not creating home directory `/var/run/proftpd'.
Adding system user `ftp' (UID 110) ...
Adding new user `ftp' (UID 110) with group `nogroup' ...
Creating home directory `/home/ftp' ...
`/usr/share/proftpd/templates/welcome.msg' -> `/home/ftp/welcome.msg.proftpd-new'
 * Starting ftp server proftpd - IPv6 getaddrinfo 'komputer02-desktop'
 error: No address associated with hostname       [ OK ]

3. Pilih standalone.
standalone
4. Membuat direktori
root@komputer02-desktop:/home# mkdir ftp_shared
root@komputer02-desktop:/home# cd ftp_shared/; mkdir upload download
Set security permission
root@komputer02-desktop:/home/ftp_shared# cd ..
root@komputer02-desktop:/home# sudo chmod 755 ftp_shared/
root@komputer02-desktop:/home# cd ftp_shared/
root@komputer02-desktop:/home/ftp_shared# sudo chmod 755 download/
root@komputer02-desktop:/home/ftp_shared# sudo chmod 777 upload/

5. Membuat user baru untuk FTP
Melalui menu System > Administration > Users and Groups kemudian klik Add user.
misalkan kita menambah user: wiwin, dengan folder homenya: /home/ftp_shared
adduser adduser
6. Mengkonfigurasi proftpd server
Langkah akhir adalah mengkonfigurasikan proftpd. File konfigurasi proftpd berada di /etc/proftpd/proftpd.conf.
Sebelumnya backup dulu file proftpd.conf dan selanjutnya edit file tersebut.
root@komputer02-desktop:/etc/proftpd# cp proftpd.conf proftpd.conf.asli
root@komputer02-desktop:/etc/proftpd# pico proftpd.conf
#
# /etc/proftpd/proftpd.conf -- This is a basic ProFTPD configuration file.
# To really apply changes reload proftpd after modifications.
# 

# Includes DSO modules
Include /etc/proftpd/modules.conf

# Set off to disable IPv6 support which is annoying on IPv4 only boxes.
UseIPv6    off

ServerName   "Debian"
ServerType   standalone
DeferWelcome   off

MultilineRFC2228  on
DefaultServer   on
ShowSymlinks   on

TimeoutNoTransfer  600
TimeoutStalled   600
TimeoutIdle   1200

DisplayLogin                    welcome.msg
DisplayFirstChdir               .message
ListOptions                 "-l"

DenyFilter   \*.*/

# Use this to jail all users in their homes
# DefaultRoot   ~

# Users require a valid shell listed in /etc/shells to login.
# Use this directive to release that constrain.
# RequireValidShell  off

# Port 21 is the standard FTP port.
Port    2008

# In some cases you have to specify passive ports range to by-pass
# firewall limitations. Ephemeral ports can be used for that, but
# feel free to use a more narrow range.
# PassivePorts                  49152 65534

# If your host was NATted, this option is useful in order to
# allow passive tranfers to work. You have to use your public
# address and opening the passive ports used on your firewall as well.
# MasqueradeAddress  1.2.3.4

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances   30

# Set the user and group that the server normally runs at.
User    wiwin
Group    nogroup

# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask    022  022
# Normally, we want files to be overwriteable.
AllowOverwrite   on

# Uncomment this if you are using NIS or LDAP to retrieve passwords:
# PersistentPasswd  off

# Be warned: use of this directive impacts CPU average load!
# Uncomment this if you like to see progress and transfer rate with ftpwho
# in downloads. That is not needed for uploads rates.
#
# UseSendFile   off

# Choose a SQL backend among MySQL or PostgreSQL.
# Both modules are loaded in default configuration, so you have to specify the backend
# or comment out the unused module in /etc/proftpd/modules.conf.
# Use 'mysql' or 'postgres' as possible values.
#
#
# SQLBackend   mysql
#

TransferLog /var/log/proftpd/xferlog
SystemLog   /var/log/proftpd/proftpd.log

<IfModule mod_tls.c>
TLSEngine off
</IfModule>

<IfModule mod_quota.c>
QuotaEngine on
</IfModule>

<IfModule mod_ratio.c>
Ratios on
</IfModule>

# Delay engine reduces impact of the so-called Timing Attack described in
# http://security.lss.hr/index.php?page=details&ID=LSS-2004-10-02
# It is on by default.
<IfModule mod_delay.c>
DelayEngine on
</IfModule>

<IfModule mod_ctrls.c>
ControlsEngine        on
ControlsMaxClients    2
ControlsLog           /var/log/proftpd/controls.log
ControlsInterval      5
ControlsSocket        /var/run/proftpd/proftpd.sock
</IfModule>

<IfModule mod_ctrls_admin.c>
AdminControlsEngine on
</IfModule>

# A basic anonymous configuration, no upload directories.

#
#   User    ftp
#   Group    nogroup
#   # We want clients to be able to login with "anonymous" as well as "ftp"
#   UserAlias   anonymous ftp
#   # Cosmetic changes, all files belongs to ftp user
#   DirFakeUser on ftp
#   DirFakeGroup on ftp
#
#   RequireValidShell  off
#
#   # Limit the maximum number of anonymous logins
#   MaxClients   10
#
#   # We want 'welcome.msg' displayed at login, and '.message' displayed
#   # in each newly chdired directory.
#   DisplayLogin   welcome.msg
#   DisplayFirstChdir  .message
#
#   # Limit WRITE everywhere in the anonymous chroot
#
#
#       DenyAll
#
#   

<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> 

#   # Uncomment this if you're brave.
#   #
#   #   # Umask 022 is a good standard umask to prevent new files and dirs
#   #   # (second parm) from being group and world writable.
#   #   Umask    022  022
#   #
#   #            DenyAll
#   #
#   #
#   #            AllowAll
#   #
#   #
#
#

7. Restart service proftpd
root@komputer02-desktop:/# /etc/init.d/proftpd restart
 * Stopping ftp server proftpd                                            [ OK ]
 * Starting ftp server proftpd                                            [ OK ]

8. Sampai di sini, konfigurasi proftpd selesai. Sekarang bisa dicoba upload file dari komputer lain ke komputer yang sudah kita setting sebelumnya. Untuk melakukan transfer file (upload, download) di windows bisa menggunakan program FileZilla atau program FTP lain.
Host – > masukkan hostname/IP komp tujuan (exp. 192.168.1.2)
Username – > masukkan username yang telah dibuat sebelumnya (wiwin)
Password – > Masukkan password dari username
Port – > Masukkan portnya (2008)
Untuk lebih jelasnya bisa dilihat gambar berikut.
filezilla
9. Untuk melakukan upload dan download dari atau ke komputer tujuan bisa dilakukan dengan drag dan drop.
upload

Tidak ada komentar:

Posting Komentar