文件服務器綜合測試(7-9題)

7. 爲服務器配置FTP服務,只在技術部網段開放FTP服務,配置基於虛擬用戶的FTP服務。。每個客戶端只允許同時建立2 個連接到FTP 服務器。技術經理使用虛擬賬戶jl可以上傳和下載,jl的根目錄爲/share/ftp/jl,jl的最大傳輸速度10M,而技術部其他人員使用虛擬賬戶user只能下載,user的根目錄爲/share/ftp/user,user的最大傳輸速度1M

#修改前將以前的vsftpd主配置文件備份一下

[root@localhost /]# cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf-

1.建立虛擬用戶文件

[root@localhost vsftpd]# vim vuser.txt
[root@localhost vsftpd]# cat vuser.txt
jl
123
user
123

2.生成用戶數據庫

[root@localhost vsftpd]# yum install db4-utils -y #安裝所需的軟件包
[root@localhost vsftpd]# db_load -T -t hash -f ./vuser.txt /etc/vsftpd/vuser.db

3.建立虛擬用戶所需的根目錄

[root@localhost vsftpd]# mkdir /share/ftp
[root@localhost ~]# mkdir /share/ftp/jl/
[root@localhost ~]# mkdir /share/ftp/user/

#給目錄設置好權限

[root@localhost vsftpd]# chmod 755 /share/ftp/*
[root@localhost etc]# chmod o+w /share/ftp/jl/

4.建立PAM認證文件
#編輯一個新認證文件

[root@localhost ~]# vim /etc/pam.d/vftp
[root@localhost ~]# cat /etc/pam.d/vftp
auth  required /lib/security/pam_userdb.so  db=/etc/vsftpd/vuser
account required /lib/security/pam_userdb.so  db=/etc/vsftpd/vuser

5.修改主配置文件,啓用虛擬用戶 

[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf
[root@localhost ~]# tail -6 /etc/vsftpd/vsftpd.conf

pam_service_name=vftp  #修改認證的文件爲vftp
guest_enable=YES  #啓用虛擬用戶功能
user_config_dir=/etc/vsftpd/vftp #定義用戶獨立配置文件的路徑
max_per_ip=2   #限制同一IP地址的併發連接數

6.爲不同的虛擬用戶建立獨立的配置文件
#虛擬用戶jl

[root@localhost ~]# mkdir /etc/vsftpd/vftp/
[root@localhost ~]# vim /etc/vsftpd/vftp/jl
[root@localhost ~]# cat /etc/vsftpd/vftp/jl

guest_username=jsjl  #虛擬用戶映射的系統賬戶
local_root=/share/ftp/jl #登錄ftp後的根目錄
anon_upload_enable=YES  #允許上傳
anon_umask=022   #上傳文件的權限掩碼
download_enable=YES  #允許下載
local_max_rate=10000000  #最大傳輸速度
#虛擬用戶user

[root@localhost ~]# vim /etc/vsftpd/vftp/user
[root@localhost ~]# cat /etc/vsftpd/vftp/user

guest_username=js1  #虛擬用戶映射的系統賬戶
local_root=/share/ftp/user #登錄ftp後的根目錄
anon_upload_enable=NO  #不允許上傳
download_enable=YES  #允許下載
local_max_rate=1000000  #最大傳輸速度

7.修改hosts.allow和hosts.deny文件只對服務器和技術部網段開放ftp服務

[root@localhost ~]# vim /etc/hosts.allow
[root@localhost ~]# grep vsftpd /etc/hosts.allow
vsftpd:192.168.30.*,192.168.0.8
[root@localhost ~]# vim /etc/hosts.deny
[root@localhost ~]# grep vsftpd /etc/hosts.deny
vsftpd:ALL


8.驗證
到技術部主機上使用ftp虛擬用戶進行上傳下載驗證

 

8. 爲服務器配置SSH服務, 限制只允許唯有技術部的這一臺測試機可以SSH到服務器上,使用密鑰認證。(10分)

技術部:
1.生成密鑰

[root@localhost ~]# ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
07:f1:f1:ce:d1:75:c2:63:dc:77:d3:04:d6:59:1c:df [email protected]
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
|        . .  o+BX|
|         o o o==@|
|        . . o...E|
|         . o .   |
|        S . o    |
|         .       |
|                 |
|                 |
|                 |
+-----------------+
2.複製密鑰到服務器端

[root@localhost ~]# ssh-copy-id 192.168.0.8

服務器

[root@localhost ~]# vim /etc/hosts.allow
[root@localhost ~]# grep sshd /etc/hosts.allow
sshd:192.168.30.*
[root@localhost ~]# vim /etc/hosts.deny
[root@localhost ~]# grep sshd /etc/hosts.deny
sshd:ALL

 

9. 爲服務器配置VNC服務,要求1號桌面開啓VNC的圖形遠程   

1.安裝所需軟件包

[root@localhost ~]# yum install "tigervnc*" -y

2.修改配置文件

[root@localhost ~]# vim /etc/sysconfig/vncservers
[root@localhost ~]# tail -3 /etc/sysconfig/vncservers
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"

3.開啓vncserver 1號端口

[root@localhost ~]# vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

4.重啓服務

[root@localhost ~]# service vncserver restart

Shutting down VNC server: 1:root                           [  OK  ]
Starting VNC server: 1:root 
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
                                                         [  OK  ]                   
#開機自啓動

[root@localhost ~]# chkconfig vncserver on

5.客戶端驗證
#技術部主機進行測試

[root@localhost ~]# vncviewer

在彈出的對話框中輸入“192.168.0.8:1”即可使用vncviewer遠程連接到服務器

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章