I am asked frequently: How can I make my own ftp server?
FTP — or file transfer protocol, was one of the original protocols used in the development of the Internet. It allows us to transfer files between a server machine (host) and a client. With the advent of peer-to-peer Bit Torrent it might seem that ftp has fallen by the wayside. Bit torrent is great, if you have a lot of the same information to share. Movies or music. But if you have only a few files to share amongst a small group of people, ftp is the way to go.
It’s not hard to implement, but there are a couple of tricks. This post will seem quite lengthy, because there’s a lot of concepts that we need to bring into focus. Security of course.
Here’s the setup. I want to use an account on my computer, that is just for sharing files with other people. Rather then have an account that only one local user can see, I need to have it visible to all local users, and to the ftp server.
So I stuck everything I wanted to share in /home/misc/example.
As always anything and including the octothorpe (#) is a comment, and need NOT be coded!
1. The first thing we will want to do is, get the software!
sudo apt-get install vsftpd # install the very secure ftp daemon
2. Let’s backup /etc/vsftpd.conf before we begin.
cd /etc # got to the /etc directory
sudo cp vsftpd.conf vsftpd.conf.bkp # make a backup copy
Here are snippets from /etc/vsftpd.conf. Use your favourite editor to change /etc/vsftpd.conf
# Anonymus FTP user Settings
#
# Allow anonymous FTP?
#
anonymous_enable=NO
#
chroot_local_user=NO
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#
chroot_list_enable=YES
#
# (default follows)
#
chroot_list_file=/etc/vsftpd.chroot_list
3. Now we edit /etc/vsftpd.chroot_list and add the userid to be jailed:
(mrtestftp is the user I am using. Change it to whatever you decide.
mrtestftp
4. We’re done changing, so restart the vsftpd daemon to re-read all the changes.
sudo service vsftpd restart
if this is the first time running this, you may need start instead of restart.
5. Let’s make sure everything worked. Take a look at the system log file with:
dmseg
and let’s look at the vsftp log:
sudo tail -25 /var/log/vsftpd.log | more
you may have never seen the tail command. This says look at the last n lines (25) and pipe the output (take the output of one programme, and make it the input to the next programme) to more. More allows us to see a screenful of data at a time. To advance to the next page, simple hit the space bar.
6. And now, the tricky part. We have to change the home directory of our user (mrtestftp) from /home/mrtestftp to /home/misc/example.
System/Administration/Users and Groups
So let’s select our user:
And this is the information we are going to change:
And we will get this warning:
6. Ensure that your user, in my case mrtestftp, is part of the group users, in /etc/group
cd /etc # go to the etc directory
sudo cp group group.bkp # make a backup copy
grep users group # check to see what users are in the group users
You should get back a line that looks like:
users:x:100:user1,user2,mrtestftp
if the userid you want to use is there, great. Next step. If NOT, then edit the file /etc/group using your favourite editor, and add them.
NOTE: ANYTIME /etc/group CHANGES ARE MADE, YOU WILL NEED TO LOGOFF/LOGIN FOR THE CHANGES TO TAKE PLACE.
7. Fire up nautilus so we can make a change to the directory:
gksudo nautilus
BE CAREFUL HERE. We are going to change the group from mrtestftp to users. This way any local user can access these files.
Alternately, you can use chgrp as well.
8. And finally, we need to change the permissions on the directory and files, so that everyone can access them:
cd /home/misc/example # navigate to the directory
sudo chmod -R g=rx example # allow the group to read and execute
or for us old guys:
sudo chmod -R 755 example # change the permissions so that the group can access
9. Testing —
:~$ ncftp -u mrtestftp wayno.abc.com
NcFTP 3.2.4 (Apr 07, 2010) by Mike Gleason (http://www.NcFTP.com/contact/).
Connecting to 72.202.67.25...
"Welcome to Wayno's FTP service. "
Logging in...
Password requested by 72.202.67.25 for user "mrtestftp".
Please specify the password.
Password: ******
Login successful.
Logged in to wayno.abc.com.
ncftp /home/mrtestftp > dir
-rw-r--r-- 1 mrtestftp mrtestftp 56580 2008-11-30 00:11 abby_n_hetty.jpg
ncftp /home/mrtestftp >
10. Browser login:
Thanks Joe.
Related Articles
No user responded in this post