Wednesday, August 10, 2011

Gambas FTP Server

Introductions:
Here we begin choosing which FTP server software is available and common, by browsing we stumbled to vsftpd, indeed it fits to our requirement. Gambas FTP client will use the vsftpd as its server and the Apache will be set-up so that we can access the data sent by the client to the FTP server via on-line.

At this time, we will need a browser hosted by apache2 and vsftpd for our FTP server , perhaps in the  second part ,its  browser will be embedded in the Gambas2 code. Or we will implement a peer to peer  FTP link between the client and the server all will be programmed in Gambas2.


Objectives:
1)To link our Gambas FTP client to Vsftpd server
2) The pulling of data is done through web browsing

Requirements:
Fedora 14 (32-63 bits)
Apache web server
Vsftpd server
libpam* or pam* libraries in Fedora


Methodology:
 
Let's install the basic requirements
root@localhost# yum install httpd
root@localhost# yum install vsftpd

Let's activate the service at start-up
root@localhost# chkconfig vsftpd on
root@localhost# yum install pam*

Let's create an account first and have its authentications
root@localhost# httpswd -c /etc/vsftpd/passwd/ cobe
root@localhost#

Or we can try also this one... * Create User to access Apache home
root@localhost# useradd -g apache -d /home/user user
root@localhost# passwd user

Set permissions to the apache2 web folder

root@localhost# vi /etc/group
apache:x:##:user

Create link to Apache home
root@localhost# ln -s /var/www/html /home/user/html

Set permissions in web root
root@localhost# chgrp -R apache *
root@localhost# chown -R apache *
root@localhost# chmod -R 775 *

Edit the vsftpd.conf

root@locahost# vim /etc/vsftpd.conf

Here are the configurations:
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
connect_from_port_20=YES
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
guest_enable=YES
user_sub_token=$USER
local_root=/var/www/sites/$USER
chroot_local_user=YES
hide_ids=YES

Running or restarting the service of Vsftpd server
root@localhost# /etc/init.d/vsftpd start
root@localhost# /etc/init.d/vsftpd stop

Then let us check if the FTP server is really working...
root@localhost# ftp localhost
or
root@localhost# ftp 127.0.0.1

Now create the home folder of "cobe" as user and the correct setting of file access permissions .
root@localhost# mkdir /var/www/cobe
root@localhost# chmod +w /var/www/cobe

This time we can have a try again logging in the FTP server
root@localhost# ftp 127.0.0.1
Connected to 127.0.0.1 (127.0.0.1).
220 Welcome to RoBook Scanner FTP service.
Name (127.0.0.1:robook): cobe
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

So let's now use our ftp client in gambas2 and upload files to vsftpd server.
Be sure to check the following:
1)Ownership of files in the folder
2)Correct IP address and its port
3) Username
4) Password
5) FTP port (if default or configured!)