1
00:00:06,574 --> 00:00:08,362
- In this lesson I'm going to show you

2
00:00:08,362 --> 00:00:12,020
how to configure a simple FTP server.

3
00:00:12,020 --> 00:00:14,783
The most common FTP
server currently on Linux

4
00:00:14,783 --> 00:00:18,700
is vsftpd, which is the
very secure FTP server.

5
00:00:20,228 --> 00:00:23,864
Let me do a yum install on vsftpd.

6
00:00:23,864 --> 00:00:25,124
Oh that's even better,

7
00:00:25,124 --> 00:00:27,602
the packets have already been installed.

8
00:00:27,602 --> 00:00:29,593
So if it has already been installed,

9
00:00:29,593 --> 00:00:32,031
setting it up is very easy.

10
00:00:32,031 --> 00:00:34,145
I will show you, but before getting there,

11
00:00:34,145 --> 00:00:35,526
I will show you the contents

12
00:00:35,526 --> 00:00:38,693
of the vsftpd.conf configuration file.

13
00:00:39,764 --> 00:00:44,030
So what we can see here
is anonymous_enable=YES,

14
00:00:44,030 --> 00:00:48,135
this allows anonymous users
to access the FTP server.

15
00:00:48,135 --> 00:00:52,239
To do so, the anonymous user
is connecting as the user FTP,

16
00:00:52,239 --> 00:00:55,611
and it will connect to the
home directory of this FTP user

17
00:00:55,611 --> 00:00:57,278
which is in var FTP.

18
00:00:58,209 --> 00:01:02,801
Also we've got local_enable,
local_enable=YES,

19
00:01:02,801 --> 00:01:06,986
local_enable=YES means that
local users can log in as well,

20
00:01:06,986 --> 00:01:09,424
which might be convenient for local users

21
00:01:09,424 --> 00:01:12,391
to get access to files in
their home directories.

22
00:01:12,391 --> 00:01:15,043
But typically it's the
anonymous user access

23
00:01:15,043 --> 00:01:18,230
that is most commonly used on FTP.

24
00:01:18,230 --> 00:01:20,547
To understand anonymous user access,

25
00:01:20,547 --> 00:01:22,782
let's first have a look
at the configuration

26
00:01:22,782 --> 00:01:27,373
of the FTP user account in /etc/passwd.

27
00:01:27,373 --> 00:01:30,678
So what we can see here
is the FTP user account

28
00:01:30,678 --> 00:01:34,114
with it's home directory set to /var/ftp,

29
00:01:34,114 --> 00:01:37,617
also we can see /sbin/nologin
as default shell,

30
00:01:37,617 --> 00:01:40,908
so this user won't ever
be able to login directly

31
00:01:40,908 --> 00:01:44,119
to a Linux shell, which
it shouldn't have to,

32
00:01:44,119 --> 00:01:46,841
because this is an FTP user, right?

33
00:01:46,841 --> 00:01:51,311
So the contents of this
home directory is /var/ftp

34
00:01:51,311 --> 00:01:53,708
in which you can see a pub directory.

35
00:01:53,708 --> 00:01:56,675
It is common to provide
everything that is accessible

36
00:01:56,675 --> 00:01:59,917
for anonymous FTP users
in the pub directory.

37
00:01:59,917 --> 00:02:02,883
So let me copy the /etc/hosts file

38
00:02:02,883 --> 00:02:04,224
to the pub directory,

39
00:02:04,224 --> 00:02:07,193
and let me also copy the /etc/motd file

40
00:02:07,193 --> 00:02:09,185
to this pub directory.

41
00:02:09,185 --> 00:02:12,268
Next I can use systemctl start vsftpd

42
00:02:13,720 --> 00:02:15,224
to start it.

43
00:02:15,224 --> 00:02:17,702
If I want this service to
be permanently available

44
00:02:17,702 --> 00:02:20,912
it's also a good idea to enable it,

45
00:02:20,912 --> 00:02:24,650
and if I also want it to be
accessible through the firewall,

46
00:02:24,650 --> 00:02:28,650
I should also use
firewall-cmd --add-service ftp

47
00:02:31,355 --> 00:02:35,743
and repeat that command
with the --permanent option

48
00:02:35,743 --> 00:02:37,369
to make it persistent.

49
00:02:37,369 --> 00:02:38,687
There's one more thing I want to do,

50
00:02:38,687 --> 00:02:40,394
and that is the installation

51
00:02:40,394 --> 00:02:43,822
of my favorite FTP command line client,

52
00:02:43,822 --> 00:02:44,989
which is LFTP.

53
00:02:46,139 --> 00:02:50,306
So yum install lftp, is
going to install it for me.

54
00:02:51,665 --> 00:02:55,929
And right now I can just
use lftp to localhost,

55
00:02:55,929 --> 00:02:58,407
as I'm not providing any
username it is connecting

56
00:02:58,407 --> 00:03:00,764
as the anonymous user by default.

57
00:03:00,764 --> 00:03:03,121
And this opens the lftp prompt.

58
00:03:03,121 --> 00:03:06,087
From within the lftp prompt
you have many commands

59
00:03:06,087 --> 00:03:08,404
that are available is
the best shell as well.

60
00:03:08,404 --> 00:03:10,151
So if you don't know what to do,

61
00:03:10,151 --> 00:03:11,817
just try the commands that you would use

62
00:03:11,817 --> 00:03:14,418
in a regular bare shell, like ls,

63
00:03:14,418 --> 00:03:17,831
which is showing the contents
of the current directory.

64
00:03:17,831 --> 00:03:20,797
And in /pub, I can see
that there is these hosts

65
00:03:20,797 --> 00:03:23,235
and these motd files.

66
00:03:23,235 --> 00:03:25,389
Now if I want to access these files,

67
00:03:25,389 --> 00:03:27,789
get would be the command to use.

68
00:03:27,789 --> 00:03:31,882
So get hosts is going to
download the file hosts

69
00:03:31,882 --> 00:03:33,467
to the current directory.

70
00:03:33,467 --> 00:03:36,392
Apparently I am in the
etc directory already,

71
00:03:36,392 --> 00:03:40,537
so it's giving me a file already
exists, which is not good.

72
00:03:40,537 --> 00:03:43,220
So if I want to avoid that,

73
00:03:43,220 --> 00:03:45,553
I can use lcd for a local cd

74
00:03:46,757 --> 00:03:49,904
to change directories on the local level.

75
00:03:49,904 --> 00:03:51,367
So that's on the Linux level

76
00:03:51,367 --> 00:03:53,886
and not on the FTP client level.

77
00:03:53,886 --> 00:03:57,096
And for right now I'm repeating
get host, you can see,

78
00:03:57,096 --> 00:03:58,929
158 bytes transferred.

79
00:04:00,103 --> 00:04:01,769
And that's all I wanted to show you

80
00:04:01,769 --> 00:04:05,061
about configuration of
a simple FTP server.

81
00:04:05,061 --> 00:04:07,255
As you can see, it's working.

82
00:04:07,255 --> 00:04:11,338
Exit to get out of the
FTP client and that's all.

