网站ftp服务器安装与配置,ftp服务器安装与配置

ftp服务器安装与配置

1. ftp服务端的安装

1

若是以前配置过ftp服务器的仍是以后配置的服务器,没法启动服务,那么基本是配置出现了错误,那么可先彻底卸载后再进行安装。若是没法定位多半是镜像源的问题,请更换阿里源。shell

sudo apt-get update sudo apt-get install vsftpd vsftpd --version //检测是否安装

1

2

3

2. ftp服务端的配置

1

vim /etc/vsftpd.conf //编辑配置文件

1

修改vsftpd.conf文件以下:ubuntu

listen=NO //是否开启监听ipv4和ipv6数据 listen_ipv6=YES //是否开启监听ipv6数据 # Allow anonymous FTP? (Disabled by default). anonymous_enable=NO //是否容许匿名登录,无需密码 # Uncomment this to allow local users to log in. local_enable=YES //是否容许本地用户登陆 # Uncomment this to enable any form of FTP write command. write_enable=YES //是否容许登录者上传文件 # Default umask for local users is 077. You may wish to change this to 022, # if your users expect that (022 is used by most other ftpd's) local_umask=022 //设置本地用户默认要减免的权限 # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=YES //目录消息,可以给远程登录的用户发送目录 # # If enabled, vsftpd will display directory listings with the time # in your local time zone. The default is to display GMT. The # times returned by the MDTM FTP command are also affected by this # option. use_localtime=YES //服务器所展现的目录将随着本地时间而改变 # # Activate logging of uploads/downloads. xferlog_enable=YES //开启上传下载的日志记录 # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES //确认链接传输的端口号为20 # You may override where the log file goes if you like. The default is shown # below. xferlog_file=/var/log/vsftpd.log //日志文件存放位置 # # If you want, you can have your log file in standard ftpd xferlog format. # Note that the default log file location is /var/log/xferlog in this case. xferlog_std_format=YES //日志文件采用标准格式 # You may fully customise the login banner string: ftpd_banner=Welcome toFTP service. //在使用shell时登录那么会发送欢迎语 # 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(). # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that # the user does not have write access to the top level directory within the # chroot) chroot_local_user=YES //对本地用户是否实施限制 chroot_list_enable=YES //开启限制白名单 # (default follows) chroot_list_file=/etc/vsftpd.chroot_list //白名单路径,若无这个文件须要本身建立 # This option should be the name of a directory which is empty. Also, the # directory should not be writable by the ftp user. This directory is used # as a secure chroot() jail at times vsftpd does not require filesystem # access. secure_chroot_dir=/var/run/vsftpd/empty # # This string is the name of the PAM service vsftpd will use. # pam_service_name=vsftpd pam_service_name=ftp //此处ubuntu的系统须要改成ftp # This option specifies the location of the RSA certificate to use for SSL # encrypted connections. rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key ssl_enable=NO # # Uncomment this to indicate that vsftpd use a utf8 filesystem. utf8_filesystem=YES //编码统一为utf8编码,能够识别中文,防止乱码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

3. vftpd配置完成

1

添加设置ftpuser用户和访问目录

1. 建立ftp用户组和用户

1

sudo groupadd ftpusers //建立ftpusers用户组 sudo useradd -m ftpuser_lxr//建立一个用户而且自动建立家目录为/home/ftpuser_lxr (第二种方式:mkdir /home/ftpuser_lxr //先建立家目录sudo userad -d /home/ftpuser_lxr ftpuser_lxr //绑定这个家目录) usermod -G ftpusers ftpuser_lxr //将这个新用户加入到ftpusers用户组中 sudo passwd ftpuser_lxr //更改密码 mkdir /home/ftpuser_lxr/ftp //为用户添加一个具备必定权限的文件夹 chmod 777 -R /home/ftpuser_lxr/ftp //新建一个pub目录用于存放文件,而且赋予所有权限 usermod -s /sbin/nologin username //限制用户登陆方式;限制用户username只能经过ftp登录,而不能直接登录服务器

1

2

3

4

5

6

7

8

2.将该用户加入vsftpd.chroot_list白名单中

1

mkdir /etc/vsftpd.chroot_list vim vsftpd.chroot_list

1

2

该文件内容以下:vim

#白名单 ftpuser_lxr

1

2

3.开启并重启vsftpd的服务

1

systemctl start vsftpd或者service vsftpd start

systemctl restart vsftpd或者service vsftpd restartwindows

测试

方法一:浏览器

打开浏览器,在地址栏输入:ftp://ip_addresss

1

方法二:服务器

在ubuntu中使用shell输入:ftp ip_address

1

方法三:ide

在windows中在文件管理器地址栏输入:ftp://ip_addresss,该方式能够上传下载文件

1

方法四:测试

在windows中使用cmd输入:ftp://ip_addresss //显示链接成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值