Tuesday, March 12, 2013

Setting up FTP server vsftpd in Fedora 16


The file transfer protocol (FTP) can be used to transfer files across different systems. In this article, I set up a secure ftp server vsftpd in my fedora machine and access the files on this server from my friend Niroj Karki’s client computer. To set up the file server on fedora you need to first install the ftp server using following command

$su
$password:
$yum –y install vsftpd.x86_64

Open the file /etc/vsftpd/vsftpd.conf and uncomment/add the following line


local_enable = YES
write_enable = YES
listen = YES
chroot_local_user=YES
chroot_list_enable=YES
userlist_file = /etc/vsftpd.userlist

Using local_enable = YES and chroot_local_user = YES you can use ftp locally. Now create a user list file inside /etc/vsftpd and add the user ftpuser into it. Here I add niroj  in the list
vi vsftpd.userlist
(press i to insert)
niroj

(I already created user niroj and added to the group ftpusers using following commands)

$ useradd –c “Niroj Karki” –d /var/www/html –s /usr/sbin/nologin niroj
And
$ usermod –a –G ftpusers niroj

Now start the ftp server using following command

$ service vsftpd start

Now the ftp server is running. Let’s put some file inside the public directory so that user can download it from their machine. Here I have added chapter1.ppt inside /var/ftp/pub directory and also inside /var/www/html directory. Finally see your firewall setting and make sure firewall allows ftp.

In client’s computer (Niroj’s computer in my case) enter the following command in terminal. (The below command try to connect to my server 10.200.1.70 from Niroj’s computer and download the file chapter1.ppt)

[niroj@localhost ~]$ ftp
ftp> open
(to) 10.200.1.70
Trying 10.200.1.70...
Connected to niroj (10.200.1.70).
220 (vsFTPd 2.3.4)
Name (10.200.1.70:niroj): niroj
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (10.200.1.70,72,41).
150 Here comes the directory listing.
drwxr-xr-x    2 0        0            4096 Feb 27 11:12 pub
226 Directory send OK.
ftp> cd pub
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (10.200.1.70,96,64).
150 Here comes the directory listing.
-rwxr-xr-x    1 0        0         4659712 Feb 27 11:12 chapter1.ppt
226 Directory send OK.
ftp> get chapter1.ppt
local: chapter1.ppt remote: chapter1.ppt
227 Entering Passive Mode (10.200.1.70,140,167).
150 Opening BINARY mode data connection for chapter1.ppt (4659712 bytes).
226 Transfer complete.
4659712 bytes received in 0.126 secs (37101.68 Kbytes/sec)
ftp>exit

1 comment:

  1. Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it,

    hopefully I can add you and follow.

    Estimation Techniques Training

    ReplyDelete