- In this lesson I'm going to show you
how to configure a simple FTP server.
The most common FTP server currently on Linux
is vsftpd, which is the very secure FTP server.
Let me do a yum install on vsftpd.
Oh that's even better,
the packets have already been installed.
So if it has already been installed,
setting it up is very easy.
I will show you, but before getting there,
I will show you the contents
of the vsftpd.conf configuration file.
So what we can see here is anonymous_enable=YES,
this allows anonymous users to access the FTP server.
To do so, the anonymous user is connecting as the user FTP,
and it will connect to the home directory of this FTP user
which is in var FTP.
Also we've got local_enable, local_enable=YES,
local_enable=YES means that local users can log in as well,
which might be convenient for local users
to get access to files in their home directories.
But typically it's the anonymous user access
that is most commonly used on FTP.
To understand anonymous user access,
let's first have a look at the configuration
of the FTP user account in /etc/passwd.
So what we can see here is the FTP user account
with it's home directory set to /var/ftp,
also we can see /sbin/nologin as default shell,
so this user won't ever be able to login directly
to a Linux shell, which it shouldn't have to,
because this is an FTP user, right?
So the contents of this home directory is /var/ftp
in which you can see a pub directory.
It is common to provide everything that is accessible
for anonymous FTP users in the pub directory.
So let me copy the /etc/hosts file
to the pub directory,
and let me also copy the /etc/motd file
to this pub directory.
Next I can use systemctl start vsftpd
to start it.
If I want this service to be permanently available
it's also a good idea to enable it,
and if I also want it to be accessible through the firewall,
I should also use firewall-cmd --add-service ftp
and repeat that command with the --permanent option
to make it persistent.
There's one more thing I want to do,
and that is the installation
of my favorite FTP command line client,
which is LFTP.
So yum install lftp, is going to install it for me.
And right now I can just use lftp to localhost,
as I'm not providing any username it is connecting
as the anonymous user by default.
And this opens the lftp prompt.
From within the lftp prompt you have many commands
that are available is the best shell as well.
So if you don't know what to do,
just try the commands that you would use
in a regular bare shell, like ls,
which is showing the contents of the current directory.
And in /pub, I can see that there is these hosts
and these motd files.
Now if I want to access these files,
get would be the command to use.
So get hosts is going to download the file hosts
to the current directory.
Apparently I am in the etc directory already,
so it's giving me a file already exists, which is not good.
So if I want to avoid that,
I can use lcd for a local cd
to change directories on the local level.
So that's on the Linux level
and not on the FTP client level.
And for right now I'm repeating get host, you can see,
158 bytes transferred.
And that's all I wanted to show you
about configuration of a simple FTP server.
As you can see, it's working.
Exit to get out of the FTP client and that's all.