In this video, I’ll show you how to configure and connect to an FTP server on Oracle Linux
8. We’ll install the vsftpd package on the
server. Look at the configuration file.
Enable the vsftpd service. And configure the firewall.
Once we've setup the server, we’ll then look at connecting to it from a client system.
We’ll install the ftp package on the client. Connect to the ftp server.
And then download and upload some files. So let’s get started by configuring the
FTP server. First we’ll install the vsftpd package and
look at the configuration file. We’ll mostly be working as root, so I’ll
enter 'sudo su'. Then I’ll enter 'dnf install vsftpd'.
And I’ll clear the screen. Settings are stored in the vsftpd.conf file.
So let’s take a look at that with 'vi /etc/vsftpd/vsftpd.conf'. I’ll leave the majority of the setting within
this file for you to explore on your own. You can take a look at the man pages to see
all the options. But I will highlight a couple of important
things. Depending on your distro, this default file
might look a little different. But for Oracle Linux 8, the default has anonymous
access disabled. It allows local users to connect and allows
users to write data. If we page forward, we can see that the log
file is stored by default in '/var/log/xferlog' directory.
And if we go down a little further, there’s a line where we can configure a welcome banner.
To keep things simple, the only thing I’ll adjust in this file is the banner, so that
we can see that change when we connect later. I’ll uncomment this line and instead of
blah, I’ll say the 'most awesome FTP service'. And I’ll save the file.
Next we’ll enable the service and configure the firewall.
I’ll use ‘systemctl enable vsftpd’. Then ‘systemctl start vsftpd’.
And to verify it’s running, I’ll use ‘systemctl status vsftpd’.
And we can see that it's active. Depending on your environment, your firewall
settings may be different. But for this demo, I’ll use 'firewall-cmd
--permanent --zone=public --add-service=ftp'. I’ll restart the firewall with 'firewall-cmd
--reload'. Then I’ll check to make sure that the ftp
service has been added to the firewall by using 'firewall-cmd --list-all'.
And we can see ftp listed as a service. Finally, we’ll want to make sure that we
have some content within the home directory of the user that we’ll be connecting with
on the client system. I’ll be using the opc user to connect.
If we use ls, we can see that I already have some files and a directory here.
But if you need something quick to test with, you can add a dummy file using fallocate.
I’ll exit out of sudo, so that we create it as the opc user.
I’ll use fallocate –l then specify a size and I'll call it ftptest.
If we use ls, we see that file in the opc home folder.
That’s it for the server setup, so next let’s take a look at connecting to it from
a client system. I’m now in the terminal on a different system
that’s going to act as the client which we’ll use to connect to the ftp server that
we just configured. The first step is to install the ftp package
with 'sudo dnf install ftp'. I’ll enter ftp and we can set the prompt
changes. If I type '?', it’ll pull up a list of valid
commands. Some of the most commonly used ones will likely
be get, to download files from the server, and put to upload files to the server.
But a handy command is the '!', which will temporarily exit the ftp prompt and drop you
back into the shell. To connect to the ftp server, I’ll use open
and then the ip address of my server system. We can see our custom welcome banner here.
And it's going to provide a suggested username, in this case, clientuser.
If I wanted to use that I could hit enter, but I want to log in as the opc user on the
server. So I’ll type opc, and I’ll enter my password.
Note that it’s allowing me to do this because we have the local_enable setting set to YES
in our vsftpd.conf file. Which allows users defined locally on the
ftp server to log in. To orient ourselves, I’ll enter pwd and
we can see that we’re in the home directory for opc.
If I use ls, it’ll provide the directory listing and I can use cd to change directories.
To download a file from the server, I can use 'get' and then the name of the file.
By default, it’s going to download into whatever working directory you were in when
you launched ftp. And to find out where that is we can type
'lcd', which shows the clientuser home directory. If type '!', we can temporarily exit the ftp
prompt. Then using ls, we can see that doc1 file in
my current home directory. But let’s say we want to place the files
we get from the ftp server into a particular directory.
I’ll create a directory with 'mkdir' and I'll call it 'downloads'.
If we type 'exit', it will take us back to the ftp prompt.
To tell it to download to a specific directory, I can use 'lcd' and then the absolute path
which is '/home/clientuser/downloads/'. Let’s download another file with 'get doc2',
which should now place it in that download folder.
To get multiple files, I can use mget. Then if I only wanted a certain file type,
I can use wildcard and specify an extension, such as '.txt'.
It’s important to note that it will only look in the working directory, it won’t
search recursively. It’ll ask if I want this particular file,
I’ll answer y for yes. And it’s going to ask me about a second
file. Again I’ll say yes.
If we jump out of ftp with '!', you can see we’re automatically in the downloads directory.
If we use 'ls', there’s the doc2 file and the text files we just downloaded.
Let’s try uploading something to the server. So I’ll change to my home directory and
I’ll create a file with 'fallocate –l' I'll specify '2MB' and I'll call it 'upload1'.
I’ll type 'exit' to go back to ftp. Then I’ll use 'put upload1'.
Ah, it says there’s no file. That’s because my ftp local directory is
still that downloads folder, so that’s where it’s looking for that upload1 file.
But that file is actually in the clientuser home directory, so I’ll need to change to
the ftp local directory with 'lcd /home/clientuser'. Now let’s try 'put upload1' and there we
go. If we us 'ls', we can see our upload1 file.
I’ll type 'close' to disconnect from the ftp server and 'exit' to quit the ftp client.
That’s all there is to configuring and connecting to an FTP server.
To learn more about Oracle Linux, check out the Oracle Linux 8 Learning Path.
And visit the Linux Learning Library for videos on Oracle Cloud Infrastructure, Oracle Linux
Virtualization Manager, and other Oracle products. Thanks for watching!