Centos7 搭建tftp/ftp Server

TFTP

开始前先关闭firwalld和selinux , 以防止无法访问或者无法上传文件报错。

#systemctl stop firewalld
#vim /etc/sysconfig/selinux
SELINUX=disable    <<<< 修改完成后重启主机
安装/配置
1.安装
#yum -y install tftp-server

2.查看tftp 状态, 没起来先把进程start
[root@xuxing ~]# systemctl status tftp    <<<<
● tftp.service - Tftp Server
   Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)    <<<<<<<<<<配置文件
   Active: inactive (dead) since Mon 2021-05-10 12:10:24 EDT; 14min ago
     Docs: man:in.tftpd
  Process: 2315 ExecStart=/usr/sbin/in.tftpd -s /home/tftpboot/ -c (code=exited, status=0/SUCCESS)
 Main PID: 2315 (code=exited, status=0/SUCCESS)

May 10 11:55:24 localhost.localdomain systemd[1]: Started Tftp Server.
May 10 11:55:24 localhost.localdomain systemd[1]: Starting Tftp Server..

3.修改配置文件如下

[root@xuxing ~]# vim /usr/lib/systemd/system/tftp.service
[Unit]
Description=Tftp Server
Requires=tftp.socket
Documentation=man:in.tftpd

[Service]
ExecStart=/usr/sbin/in.tftpd -s /home/tftpboot/ -c       <<<<<<<     设置tftp目录, -c 代表可创建文件
StandardInput=socket

[Install]
Also=tftp.socket

4.修改完成后重启进程

#systemctl daemon-reload
#systemctl restart tftp

参考文章

https://blog.csdn.net/shishui07/article/details/84980866

FTP

FTP 找了一下配置的文章, 过于复杂, 索性直接使用docker run一个简单的FTP server。

开始前配置一个无法login的用户guest

#useradd -s /sbin/nologin guest
#passwd guest
安装/配置
[root@xuxing ~]# docker run -d -v /home/guest:/home/vsftpd \
> -p 20:20 -p 21:21 -p  21100-21110:21100-21110 \
> -e FTP_USER=guest -e FTP_PASS=guest \
> -e PASV_ADDRESS=10.70.80.197 \
> -e PASV_MIN_PORT=21100 -e PASV_MAX_PORT=21110 \
> --name vsftpd --restart=always fauria/vsftpd


-p  做宿主机端口映射
PASV_ADDRESS: 宿主机地址

参考文章

https://www.hangge.com/blog/cache/detail_2449.html
  1. Linux’s avatar

    Hi Xu,

    For IOS,IOS-XE,IOS-XR, all platform support sftp.
    maybe the best is sftp.
    also the Linux default support sftp. don’t need install and config.

    Reply

Reply

Your email address will not be published.