Instructor: Hi.
In this lesson we are going to cover FTP,
which stands for file transfer protocol.
The FTP is a standard network protocol used for the transfer
of computer files between a client
and a server on a computer network.
FTP is built on a client server model architecture
using separate control and data connections
between the client and the server.
This is the definition that I have
actually got it from exactly from Wikipedia.
In very simple words,
an FTP is a protocol that is used
to transfer a file from server A to server B.
Now the protocol is actually a set of rules
used by computers to communicate.
So that's a protocol that tells a computer,
hey, this is how it should be transferred.
This is the port that you should use.
This is an encryption that you should use.
These are all defined rules
that are already built in within a computer
and an operating system.
For the FTP, the default FTP port is 21.
Just like for SSH we have 22, for DNS we have 53,
and for many other services that we run in a Linux
for FTP we use port 21
to communicate from one server to another.
Now, for this lecture, we need two Linux machines.
If you do not have two Linux machine,
I will recommend you that you should go ahead
and build another Linux machine running CentOS,
which could be the exactly the same one
as you had previously.
So my first machine that I've been using
is MyFirstLinuxVM.
This is a host name.
And the second machine that I created,
and I'm referring it to as the host name as a LinuxCentOS7.
It's just a version, it's just a name that I picked.
So anyway, I'm sure you already have MyFirstLinuxVM,
CentOS VM.
And what you need to do is to install another Linux VM.
So if I gave you a quick
information on the Oracle Virtualbox,
you see this is the first VM that I was running,
and this is the information it has.
One gig machine, 10 giga, sorry, disc space.
The second machine that I'm using as a server
is also has the same specification, 10 gig, one gig,
everything exactly the same.
Even I'm using the same version of CentOS as well.
So, but I am using, I built a second one
so we could go through this lesson, sorry.
Alright, so to put in a graphical way, let's go into detail.
So we have a client, a server that needs to send a file
to another server.
Let's call it server A and server B.
And whenever you have one server
trying to connect to another server,
that recipient becomes a server,
and the sender becomes a client.
So it wants to send a file over FTP protocol.
Now, if this recipient server,
if it's not running any kind of listening service
to receive that protocol,
then it's gonna reject that transfer.
So we need to make sure that it is running FTPD,
daemon, or the service, or the application on that server.
And by default, whenever we run it,
it will start up that service on port 21.
Alright, now what is the process to actually configure that
on client and server?
So let's look at the server side first.
So here are the quick steps that we'll cover
to do the installation configuration
of FTP on the remote server.
After becoming a root,
we'll check if we have FTP server installed.
We'll check if we have internet connectivity.
We'll install the VSFTPD package on the server,
and then we'll modify the VSFTPD.configuration file.
And in that file we'll make certain configuration changes.
And these changes are here listed.
We'll go over them one by one,
and that will start the service.
We'll enable the service so it could start at boot time.
We'll stop the firewall D
so the communication can take place
between server A and server B.
If you wanted to leave your firewall D up and running,
then you have to add a rule for it to allow
to accept port or traffic 21.
So a traffic on port 21.
You could find that online how to add FTP port
on the firewall D.
And then you could disable that firewall D.
If you're not using it, just disable it
so it won't start back online.
And the last step is of course,
make sure you create a user account
on that FTP server if you do not already have it,
because that's the account we will use
to transfer file from server A to server B.
And the last part would be we will install FTP client
on the client server.
We'll become root, yum install FTP, become a regular user,
and then we will create a file called Kruger.
Now this is just a regular file.
You could actually use any file name you would like.
You could pick pizza, pasta, whatever the file name.
But if you want to be consistent staying with me,
just make a file called Kruger.
Once the file is created, then we'll FTP to the server.
We'll enter our credentials.
We'll put in a BI for binary,
and then hash for hashtagging so you could see the progress,
and we'll use the command put Kruger.
Once it's transfer, then we simply type bye
to get out of that FTP process.
Alright, so now let me go back to the installation process
of FTP on the server.
Alright, as I said for that I have a client,
which is my first,
and which is the very first Linux VM that I created,
and I called it MyFirstLinuxVM.
And then I have another machine
that I'm using for this lecture purpose,
and then that machine I'm calling LinuxCentOS.
Now in this machine, once you have it built and configured,
I want you to become root.
By the way, I was logged in as myself.
So if I exit and I do, who am I,
you're gonna see that on this server
I have already created an account, Iafzal.
So if you do not have a account during the installation,
you didn't create it, go ahead and create it.
If you have it, good.
Now become root.
After becoming root, of course you could do who am I
just to confirm which users you are logged in as.
Now you need to install the FTP daemon,
or the FTP service on your machine.
Before you install it,
check if it has already been installed.
So I would recommend you type RPM-QA and grep for VSFTPD.
This is the name of the package that needs to be downloaded.
Okay, it is not downloaded,
and it has not been installed.
So I will run the command.
Before I run the command
or before I go out on the CentOS repository to install it,
I wanted make sure this machine
that I'm logged in right now has internet access.
So I'll do simply ping www.google.com,
and you see I'm getting a response back.
Perfect.
So it means I have internet connectivity.
Now I'll go ahead and do yum install VSFTPD.
Now, this command is going to all the repositories,
and it is checking, hey, do you have VSFTPD package
that I need to download and then install?
It did.
It did go there, it checked,
and it says yes I do have it.
And this is for architecture 64 bit,
and the version that I have, the latest one is 3.0.2.
Do you want to download?
And the size is 171k.
Yes, I do want it to download.
So simply type Y and hit enter.
It's saying downloading package,
and then it's saying it has a fingerprinting,
some information, some security information.
Is this okay that it comes with a package?
That is fine.
Go ahead and click yes.
Running transaction, check running transaction test.
It will go through the process of fetching that package,
downloading the package, installing the package,
and then verifying the installation.
And at the end you say it is completed
and verified of course.
Now if you run that same command, RPM-QA
and grep four VSFTPD,
you will see it will show up the package that is installed.
There you go.
This is the package that it installed.
So we confirmed that it has been downloaded,
and of course it is installed.
Now we need to configure it.
So every time you hear the word configure,
it means we have to configure it on the configuration file.
The configuration file for FTP server is
ect/vsftpd/fsftpd.conf file.
So before I modified,
I always recommend that you make a copy of it.
So let's go to CD vsftpd.
Do ls-ltr,
and you'll see this is the file.
Now I want you to go ahead and make a copy of that.
So copy cp vsftpd.conf, vsftpd.conf.orig.
This is the name I usually pick to make a copy.
As it's reads, it will tell me
that this is the actual original file.
All right, the copy or the backup has been created.
Now I need to modify that file vsftpd.conf file.
And now I have to go through these parameters
that I have listed on my slide to modify these parameters.
The first thing is find the following lines
and make the changes as shown below.
Disable anonymous login.
So I will search for /anonm, sorry y, mous, anonymous.
It took me to the first word
because I'm doing a search within bi.
It took me the first word,
but this is not the line that I'm looking for.
So I'm gonna hit N to go to the next one.
And there it is.
It says anonymous_enable,
and it is yes.
So go ahead and remove that and put no
because you don't want anyone else
to come into your FTP server as anonymous.
Good.
Next parameters is A-S-C-I-I, ascii.
And now you have to uncomment these two lines.
Upload enabled, download enabled.
That's perfectly fine.
Now come down to where it says FTPD.
Search for that.
And there it is.
It says FTPD_banner.
Welcome to blah FTP server.
That is fine.
You could remove that, uncommented.
Now, if you wanted to change to welcome to blah FTP server
to welcome to my beautiful FTP server,
that is fine, you could do that.
Now the last thing it says add at the end of this file.
If you want to go to the end of this file,
you have to press shift G, and it will take you to the end.
And here I'm just gonna put, first I'm gonna put comment
as local time,
and I'm gonna put in the parameters.
It says use_local time=yes.
Perfect, that's only,
these are the only configuration changes you have to make.
Now go ahead and save the file.
Perfect, file is saved.
Now it's time to start the VSFTPD service.
And for that we have to use the command system,
CTL start, VSFTPD.
It is started.
Let's check the status if it is actually started or not.
Yes, it says started.
See active here.
Beautiful.
Now I want to enable that.
So every time my system reboots, I don't have to go back
and start that service manually again.
I want that service to start every time
that the system reboots.
And for that I have to use a command system,
CTL enable VSFTPD, hit enter,
and it is our, it has been enabled now.
Perfect.
Now I want to disable the firewall on the server.
To disable it, I'll use the command.
Before I disable, I need to stop it.
So stop firewall D.
Now as I said earlier,
if you do not want to disable firewall D,
which I don't recommend you.
I'm disabling it because this is my lab environment,
so I'm okay.
So if you're in a production environment,
and you have firewall D running,
then you need to add the rule to allow port 21 to,
as an incoming traffic for that firewall.
Anyway, going back, let's stop the firewall D
because I'm using my lab, and I really don't need that.
It is stopped.
Now let's check the status.
See right here it says inactive, dead.
Perfect.
Now I want you to disable it.
Meaning every time my computer reboots,
I don't want this service to start back again.
It is disabled.
Perfect, beautiful.
We did our work on the server side.
And the last line you're gonna see it says useradd Iafzal,
if the user does not exist already.
When I do exit, I would have the root,
and I do who am I.
You see I already have an account.
My account, Iafzal on this machine.
So I don't need to recreate.
If you do not have the account
or if you do not have an account that you will be using
for the FTP purpose,
then I want you to go ahead and create an account.
Anyways, so this is the configuration we followed
on the FTP, sorry, on the FTP server.
Now we have to do few things on the FTP client.
So the client needs to install FTP, the package.
And to do that, let's go into our client.
And my client is right here.
This is MyFirstLinuxVM.
Perfect.
Now here, if I become root-
By the way, I was logged in as Iafzal.
Now if I run FTP command, you see it says
bash FTP command not found.
The reason it is not found
because I do not have the FTP client installed.
So I need to install the client.
Now of course, as I said, always check to make sure you have
internet connectivity.
And for that ping any website that you like online,
and it says I am getting the response back.
Perfect.
Now I could go ahead and do yum install FTP.
Now this is not the VSFTPD, this is FTP.
So we are installing the client part here,
not the server package.
Alright, so once you do yum install FTP,
it will go online, check for the package,
and it says running transaction check package.
This will be installed.
Perfect, this is what I want,
the version number, so and so and the size has been 61k.
That's perfect.
Go ahead Y.
Okay, transaction test succeeded, verifying it,
installing it, verifying it, and completed.
Beautiful.
So now if you type FTP and just simply hit enter,
you see it actually took that command,
and it brought you into the FTP interactive session.
You don't want to use that right now.
Just click bye so you could get out
and get your prompt back.
Now I want you to become Iafzal again.
You could do SU-Iafzal,
or of course in this case it's yourself,
but, or you could just simply do exit,
and it will bring you back to your own user account, Iafzal.
All right, so if I do LS-LTR, these are the directories
and files I have right now in my home directory.
So this is home directory.
Okay, now I want to create a file called Touch Kruger.
It is created.
If you do LS-LTR you see it has zero bytes,
and right here it says zero bytes.
If you want to add something to it,
let's say I will do LS-LTR.
I'll put that to Kruger.
Perfect.
Now when you do LS-LTR,
you see now it has total of 517 bytes.
If you do CAD on Kruger,
you're gonna see basically the output of exactly LS-LTR.
Anyway, so why did I do that?
No reason.
I just wanted to have some information in that file.
You could have done VI and typed in something else
like VI Kruger.
Like this is my file, blah, blah.
Anyway, I just wanted to populate that file
with some information so it won't be zero bytes.
Now, right now it has 545 bytes.
Alright, beautiful.
We're moving along.
Now we have the file.
Now the question is, I want to transfer that Kruger file
to the server.
And the server is the one where we installed
that FTPD package.
So in order to transfer the file over to the server,
we need to know the IP address of that server.
So I'll go back into my server.
This is my server.
For the IP address, I will type if config.
And if I move up, you're gonna see the IP address
for enp0s3.
The signed one is 192.168.1.58.
Please use IPA command if you are on a newer version
of Red Hat or CentOS system.
Perfect, we got the IP address.
Now I'm gonna do FTP 192.168.1.58.
Hit enter.
Beautiful, there you go.
It says welcome to blah FTP server.
See that blah thing.
I told you if you wanted to put it like beautiful here,
it would show beautiful there.
Okay, so anyway, it says name, and IP address,
and the username is Iafzal.
So by default it picked the username
that I've been trying to FTP it over.
If you wanted to use a different username,
then you will specify here.
Let's say you wanted to use John or whatever,
but I wanted to use my own name Iafzal.
So I'm not gonna enter anything.
I'm gonna leave it as default,
and I'm gonna go ahead and hit enter.
Please specify the password.
This is the password of your Iafzal account to that server,
or to that remote machine.
It says 230 login successful remote system type
is Unix using binary mode to transfer files.
Perfect.
Now what I need to do, I want you to type bi
or bin as switching to binary mode
because you want it to transfer the file
always using FTP through the binary mode.
That is fine.
Then I want you to type hash,
hash meaning when you doing the transfer,
show me the hashtags, which will show,
which will tell me that there's a progress going on
in hashtag progress.
Now time to put the file.
So whenever you, when it's time to transfer,
you use the command put
because you are going from A to B.
And do Kruger.
Hit enter.
Right here it says, as soon as you hit,
put Kruger, local Kruger remote, entering passive mode 150,
okay to send data, hashtag.
Remember this is a progress.
If it was a huge file, you would've seen so many hashtags.
226 transfer complete.
545 bytes sent.
This is the size of my file, 545 sent succeeded.
Perfect.
Now you could just do bye.
Now you are back out to your machine.
Now do you want to confirm on the server
if has been transferred?
Of course, yes.
Let's go to the server.
I am in my home directory.
And let's do LS-LTR.
And you're gonna see right here, this is Kruger.
This is the file transfer.
That's how the FTP file transfer works.
I hope this lecture actually has served its purpose,
and you know how the FTP works.
If you have any question,
please do not hesitate to contact me.
I'm here to help you.
So let's go and work this FTP server
and learn this thing together.
Good luck.