日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux下FTP服务器搭建

發(fā)布時間:2025/4/16 linux 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux下FTP服务器搭建 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Linux下FTP服務(wù)器搭建

  • 一、FTP介紹
  • 二、環(huán)境介紹
  • 三、FTP服務(wù)端搭建步驟
    • 1.安裝相關(guān)軟件包
    • 2.啟動FTP并檢查狀態(tài)
    • 3.檢查服務(wù)端口運行狀態(tài)
    • 4.修改FTP配置文件
    • 5.關(guān)閉selinux及防火墻
  • 三、客戶端操作
    • 1.安裝軟件包
    • 2.查看客戶端狀態(tài)
  • 四.客戶端測試登錄情況
    • 1.使用客戶端本地賬號user1登錄
    • 2.測試上傳下載文件

一、FTP介紹

FTP(File Transfer Protocol,文件傳輸協(xié)議) 是 TCP/IP 協(xié)議組中的協(xié)議之一。FTP協(xié)議包括兩個組成部分,其一為FTP服務(wù)器,其二為FTP客戶端。默認情況下FTP協(xié)議使用TCP端口中的 20和21這兩個端口,其中20用于傳輸數(shù)據(jù),21用于傳輸控制信息。但是,是否使用20作為傳輸數(shù)據(jù)的端口與FTP使用的傳輸模式有關(guān),如果采用主動模式,那么數(shù)據(jù)傳輸端口就是20;如果采用被動模式,則具體最終使用哪個端口要服務(wù)器端和客戶端協(xié)商決定。

二、環(huán)境介紹

FTP服務(wù)端:hostname為control IP:192.168.200.150
FTP客戶端:hostname為node1 IP: 192.168.200.135

三、FTP服務(wù)端搭建步驟

1.安裝相關(guān)軟件包

[root@control ~]# yum -y install ftp.x86_64 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Last metadata expiration check: 0:01:45 ago on Tue 11 May 2021 06:57:05 PM CST. Dependencies resolved. ====================================================================================================================================================================Package Arch Version Repository Size ==================================================================================================================================================================== Installing:ftp x86_64 0.17-78.el8 AppStream 70 kTransaction Summary ==================================================================================================================================================================== Install 1 PackageTotal size: 70 k Installed size: 112 k Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transactionPreparing : 1/1 Installing : ftp-0.17-78.el8.x86_64 1/1 Running scriptlet: ftp-0.17-78.el8.x86_64 1/1 Verifying : ftp-0.17-78.el8.x86_64 1/1 Installed products updated.Installed:ftp-0.17-78.el8.x86_64 Complete!

2.啟動FTP并檢查狀態(tài)

[root@control ~]# systemctl enable --now vsftpd Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /usr/lib/systemd/system/vsftpd.service. [root@control ~]# systemctl status vsftpd ● vsftpd.service - Vsftpd ftp daemonLoaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)Active: active (running) since Tue 2021-05-11 18:59:51 CST; 9s agoProcess: 2825 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)Main PID: 2826 (vsftpd)Tasks: 1 (limit: 24900)Memory: 864.0KCGroup: /system.slice/vsftpd.service└─2826 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.confMay 11 18:59:51 control systemd[1]: Starting Vsftpd ftp daemon... May 11 18:59:51 control systemd[1]: Started Vsftpd ftp daemon.

3.檢查服務(wù)端口運行狀態(tài)

[root@control mail]# netstat -antup | grep ftp tcp6 0 0 :::21 :::* LISTEN 2826/vsftpd

4.修改FTP配置文件

anonymous_enable=YES local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=YES anon_mkdir_write_enable=YES dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_std_format=YES listen=YES listen_ipv6=NOpam_service_name=vsftpd userlist_enable=YES

5.關(guān)閉selinux及防火墻

sed -i 's/SELINUX=enforcing/SELIUNUX=disabled/' /etc/selinux/configsystemctl stop firewalld.service

備注:
防火墻如果要開啟,則可開啟以下端口:

firewall-cmd --zone=public --add-port=20/tcp --permanent firewall-cmd --zone=public --add-port=21/tcp --permanent firewall-cmd --zone=public --add-port=22/tcp --permanent firewall-cmd --zone=public --add-port=30000-35000/tcp --permanent

三、客戶端操作

1.安裝軟件包

[root@node1 ~]# yum -y install lftp Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Repository AppStream is listed more than once in the configuration Repository BaseOS is listed more than once in the configuration ansiable 0.0 B/s | 0 B 00:00 Failed to synchronize cache for repo 'ansiable', ignoring this repo. Last metadata expiration check: 0:00:17 ago on Tue 11 May 2021 07:04:23 PM CST. Dependencies resolved. ====================================================================================================================================================================Package Arch Version Repository Size ==================================================================================================================================================================== Installing:lftp x86_64 4.8.4-1.el8 AppStream 885 kTransaction Summary ==================================================================================================================================================================== Install 1 PackageTotal size: 885 k Installed size: 3.0 M Downloading Packages: Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transactionPreparing : 1/1 Installing : lftp-4.8.4-1.el8.x86_64 1/1 Running scriptlet: lftp-4.8.4-1.el8.x86_64 1/1 Verifying : lftp-4.8.4-1.el8.x86_64 1/1 Installed products updated.Installed:lftp-4.8.4-1.el8.x86_64 Complete!

2.查看客戶端狀態(tài)

[root@node1 ~]# ps -ef |grep ftp root 1746 1745 0 18:56 ? 00:00:00 /usr/libexec/openssh/sftp-server

四.客戶端測試登錄情況

1.使用客戶端本地賬號user1登錄

lftp 192.168.200.150:~> pwd ftp://192.168.200.150 lftp 192.168.200.150:~> user user1 Password: lftp user1@192.168.200.150:~> ls -rw-r--r-- 1 0 0 3541 May 11 13:08 passwd lftp user1@192.168.200.150:~> pwd ftp://user1@192.168.200.150/%2Fhome/user1

2.測試上傳下載文件

[root@node1 ~]# lftp 192.168.200.150 lftp 192.168.200.150:~> user user1 Password: lftp user1@192.168.200.150:~> ls -rw-r--r-- 1 0 0 3541 May 11 13:08 passwd lftp user1@192.168.200.150:~> lcd /etc lcd ok, local cwd=/etc lftp user1@192.168.200.150:~> put group 1154 bytes transferred lftp user1@192.168.200.150:~> get passwd get: /etc/passwd: file already exists and xfer:clobber is unset

總結(jié)

以上是生活随笔為你收集整理的Linux下FTP服务器搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。