服务管理-文件服务器
FTP工作原理
FTP Transfer Protocol 傳輸協(xié)議的縮寫。
FTP會話包含了兩個通道,一個叫控制通道,一個叫數據通道。
控制通道:控制通道是和FTP服務器進行溝通的通道,鏈接FTP,發(fā)送FTP指令都是通過控制通道來完成的。 數據通道:數據通道是和FTP服務器進行文件傳輸或者列表的通道。FTP協(xié)議中,控制連接均有客戶端發(fā)起,而數據鏈接有兩種方式:PORT方式和PASV方式
PORT模式(主動方式)
PORT模式簡歷數據傳輸通道是由服務器端發(fā)起的,服務器使用20端口鏈接客戶端的某一個大于1024的端口。 FTP客戶端首先和FTP 服務端的tcp 21端口建立連接,通過這個通道發(fā)送命令,客戶端需要接受數據的時候在這個通道上發(fā)送PORT命令。PORT命令包含了客戶端用什么端口(大于1024 的端口)接受數據,在傳送數據的時候,服務器端通過自己的TCP 20 端口發(fā)送數據,FTP 服務端必須和客戶端建立一個新的鏈接來傳送數據。
客戶端使用1024以上的端口鏈接服務器的21號端口,并且會實現開啟一個1024+N的dua扣準備讓服務器來鏈接,服務器得知客戶端準備的端口后,用20號端口與客戶端鏈接,其中21號端口稱為鏈接鏈路,20號端口稱為數據鏈路,創(chuàng)建數據鏈路時server端處于主動鏈接客戶端的狀態(tài),稱為:主動傳輸模式。
PASV模式(被動方式)
PASV模式中,數據傳輸的通道的建立是由FTP客戶端發(fā)起的,他是用一個大于1024的端口鏈接服務器的1024以上的某一個端口。在建立控制通道的時候和PORT模式類似,當客戶端通過這個通道發(fā)送PASV命令的時候,FTP server打開一個大于1024的隨機端口并進行數據的傳輸,這個時候FTP server 不再需要建立一個新的
和客戶端之間的鏈接傳送數據。
客戶端使用1024以上的端口鏈接服務器端的21端口,服務器接到鏈接請求后,開啟一個1024+M的端口,等待客戶端來鏈接,在通知客戶端這個等待連接的端口號是1024+M,客戶端接到服務器端的信息后,開啟新的一個1024+N的端口與1024+M進行鏈接,其中21號端口為連接鏈路,1024+M端口為數據鏈路,創(chuàng)建數據鏈接時,server端處于被客戶端鏈接的狀態(tài),所以稱為:被動傳輸模式。
[root@localhost ~]# cat /etc/vsftpd/vsftpd.conf # Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings are fairly paranoid. This sample file # loosens things up a bit, to make the ftp daemon more usable. # Please see vsftpd.conf.5 for all compiled in defaults. # # READ THIS: This example file is NOT an exhaustive list of vsftpd options. # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's # capabilities. # # Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=YES # 匿名用戶是否可以訪問FTP # # Uncomment this to allow local users to log in. # When SELinux is enforcing check for SE bool ftp_home_dir local_enable=YES # 本地用戶是否登錄 # # Uncomment this to enable any form of FTP write command. write_enable=YES # 允許FTP的寫指令 # # 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 # 本地用戶建立文件的權限 # # Uncomment this to allow the anonymous FTP user to upload files. This only # has an effect if the above global write enable is activated. Also, you will # obviously need to create a directory writable by the FTP user. # When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access #anon_upload_enable=YES # 允許匿名用戶創(chuàng)建文件 # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES # 允許匿名用戶創(chuàng)建新目錄 # # Activate directory messages - messages given to remote users when they # go into a certain directory. dirmessage_enable=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端口 # # If you want, you can arrange for uploaded anonymous files to be owned by # a different user. Note! Using "root" for uploaded files is not # recommended! #chown_uploads=YES #chown_username=whoever # # You may override where the log file goes if you like. The default is shown # below. #xferlog_file=/var/log/xferlog # 日志文件位置 # # 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 change the default value for timing out an idle session. #idle_session_timeout=600 # 空閑鏈接超時 # # You may change the default value for timing out a data connection. #data_connection_timeout=120 # 數據傳輸超時 # # It is recommended that you define on your system a unique user which the # ftp server can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure # # Enable this and the server will recognise asynchronous ABOR requests. Not # recommended for security (the code is non-trivial). Not enabling it, # however, may confuse older FTP clients. #async_abor_enable=YES # # By default the server will pretend to allow ASCII mode but in fact ignore # the request. Turn on the below options to have the server actually do ASCII # mangling on files when in ASCII mode. # Beware that on some FTP servers, ASCII support allows a denial of service # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd # predicted this attack and has always been safe, reporting the size of the # raw file. # ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES #ascii_download_enable=YES # # You may fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. # # You may specify a file of disallowed anonymous e-mail addresses. Apparently # useful for combatting certain DoS attacks. #deny_email_enable=YES # (default follows) #banned_email_file=/etc/vsftpd/banned_emails # # 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 # # You may activate the "-R" option to the builtin ls. This is disabled by # default to avoid remote users being able to cause excessive I/O on large # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume # the presence of the "-R" option, so there is a strong case for enabling it. #ls_recurse_enable=YES # # When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=NO # # This directive enables listening on IPv6 sockets. By default, listening # on the IPv6 "any" address (::) will accept connections from both IPv6 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 # sockets. If you want that (perhaps because you want to listen on specific # addresses) then you must run two copies of vsftpd with two configuration # files. # Make sure, that one of the listen options is commented !! listen_ipv6=YESpam_service_name=vsftpd # 定義PAM所使用的名稱 userlist_enable=YES # user_list文件有效, tcp_wrappers=YES # 開啟tcp_wrappers支持 [root@localhost ~]#?FTP本地用戶訪問
首先安裝ftp:yum install ftp ,,,然后通過ftp即可在本地訪問
首先確保下面三項為YES
anonymous_enable=YES anon_upload_enable=YES anon_mkdir_write_enable=YES [root@localhost ~]# systemctl start vsftpd.service [root@localhost ~]# systemctl status vsftpd.service ● vsftpd.service - Vsftpd ftp daemonLoaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)Active: active (running) since 三 2018-09-12 11:12:50 CST; 1s agoProcess: 57386 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)Main PID: 57388 (vsftpd)CGroup: /system.slice/vsftpd.service└─57388 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf9月 12 11:12:49 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon... 9月 12 11:12:50 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon. [root@localhost ~]#NFS服務器
NFS最初是由SUN公司開發(fā)的,目的就是在計算機不同操作系統(tǒng)之間可以彼此共享文件,NFS配置簡單,快捷。客戶端可以通過mount掛載之后像使用本地文件系統(tǒng)一樣來只用遠端共享目錄。
在centos 7 上搭建NFS服務器比以往其實更加簡單,卸掉了protmap服務,而是用rpcbind服務。
NFS服務器實現共享
/etc/exports 文件指定了那個文件系統(tǒng)的NFS應該輸出(有時候也可以稱之為“共享”)
/etc/exports 里面每行指定一個輸出的文件系統(tǒng)和那些機器可以訪問該文件系統(tǒng)。
在指定機器訪問權限的同時,訪問選項開關也可以被指定。
/ect/export 格式:
共享目錄 主機1或ip1(選項1,選項2) 主機2或ip2(選項3,選項4)主機名稱格式:
單個主機/IP:station1.uplooking.com 192.168.1.1 IP網絡: 192.168.1.0/255.255.255.0 172.16.1.0/15 通配符: *.uplooking.com一般選項:
ro :read only rw :允許nfs read write 請求 sync:同步存儲后回應請求 async:在同步之前回應請求用戶ID映射:
root_squash :映射uid/gid 0 到匿名 uid/gid no_root_squash: 關閉root squashing all_squash:映射所有的uid/gid到匿名的uid/gid anonuid and anongid:映射uid/gid到指定的uid/gidexportfs 命令用來管理當前NFS共享的文件系統(tǒng)列表。這個列表保存在一個單獨的文件/var/lib/nfs/etab中,當遠端主機要求對一個文件系統(tǒng)樹加載并訪問時由mountd讀取,列表中活動的一部分也保存在內核共享表中。通常etab在執(zhí)行exportfs -a。的時候,根據/etc/exports中定義的共享列表來初始化。但是,管理員可以選擇添加或者刪除獨立的文件系統(tǒng),不必修改/etc/exports,只要執(zhí)行exportfs就可以了
-a:全部掛載(或卸載) /etc/exports 文件內的設定。 -r :重新掛載/etc/exports中的設置,此外同步更新/etc/exports以及/var/lib/nfs/etab中的內容 -u:卸載某一目錄 -v:在export時將共享的目錄顯示在屏幕上 [root@localhost ~]# exportfs -rv # 全部重新export一次 [root@localhost ~]# exportfs -au # 全部卸載 [root@localhost ~]#。。。更多請移駕百度。。。
Samba服務器
Samba,是一種自由軟件,用來讓Unix系列的操作系統(tǒng)與微軟Windows操作系統(tǒng)的SMB/CIFS網絡協(xié)議做聯(lián)結。
應用環(huán)境:
文件和打印機共享:文件和打印機共享是Samba的主要功能,SMB進程實現資源的共享,將文件和打印機發(fā)布到網絡之中,以供用戶可以訪問。 身份驗證和權限設置:smbd服務支持user mode和domain mode等身份驗證和權限設置模式,通過加密方式可以保護共享的文件和打印機。 名稱解析:Samba通過nmbd服務可以搭建NBNS服務器,提供名稱解析,將計算機的NetBIOS名解析為IP地址。 瀏覽服務:局域網中,Samba服務器可以成為貝蒂主瀏覽服務器(LMB),保存可用資源列表,當使用客戶端訪問Windows網上鄰居時,會提供瀏覽器列表,顯示共享目錄,打印機等資源更多請百度。。等用到了再補充。。
?
轉載于:https://www.cnblogs.com/52-qq/p/9634059.html
總結
以上是生活随笔為你收集整理的服务管理-文件服务器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: #386. 【UNR #3】鸽子固定器
- 下一篇: 项目成本管理(二)