搭建sam使用者認證伺服器

2021-09-09 06:39:43 字數 3389 閱讀 4797

服務端 wangxiaolan 172.16.30.11

客戶端 chenwanli 172.16.30.111

//安裝samba伺服器

[root@wangxiaolan ~]# yum -y install samba-*
//對映共享目錄:

//建立使用者wangqing:

[root@wangxiaolan ~]# useradd -m wangqing
//為cwl使用者建立smb共享密碼:
[root@wangxiaolan ~]# smbpasswd -a wangqing

new smb password:

retype new smb password:

added user wangqing.

//為對映cwl使用者為wxl使用者,在/etc/samba/smbusers檔案中新增如下內容:
[root@wangxiaolan ~]# echo 'cwl = share' > /etc/samba/smbusers
//在全域性配置中新增如下內容:
[root@wangxiaolan ~]# vim /etc/samba/smb.conf

# see smb.conf.example for a more detailed config file or

# read the smb.conf manpage.

# run 'testparm' to verify the config is correct after

# you modified it.

[global]

workgroup = samba

security = user

username map = /etc/samba/smbusers

//建立乙個共享目錄cwl
[[root@wangxiaolan ~]# mkdir /opt/cwl

[root@wangxiaolan ~]# chown -r cwl.cwl /opt/cwl

[root@wangxiaolan ~]# ll /opt/

total 0

drwxr-xr-x. 2 cwl cwl 15 1月 15 11:30 cwl

//配置共享
[root@wangxiaolan ~]# cat >> /etc/samba/smb.conf <[cwl]

> comment = cwl

> path = /opt/cwl

> browseable = yes

> guest ok = yes

> writable = yes

write list = wxl

> public = yes

>eof

[root@wangxiaolan ~]# tail -8 /etc/samba/smb.conf

[cwl]

comment = cwl

path = /opt/cwl

browseable = yes

guest ok = yes

writable = yes

write list = wxl

public = yes

//啟動並重啟smb服務:
[root@wangxiaolan ~]# systemctl start smb

[root@wangxiaolan ~]# systemctl restart smb

[root@wangxiaolan ~]# systemctl reload smb
//設定smb服務隨系統啟動而啟動:
[root@wangxiaolan ~]# systemctl enable smb
//在客戶機檢視samba伺服器有哪些共享資源

[root@chenwanli ~]# smbclient -l 172.16.30.11 -u wxl

enter wxl's password:

domain=[mygroup] os=[unix] server=[samba 4.1.1]

sharename type comment

--------- ---- -------

ipc$ ipc ipc service (samba server version 4.1.1)

cwl disk cwl

domain=[mygroup] os=[unix] server=[samba 4.1.1]

server comment

--------- -------

workgroup master

--------- -------

//關閉(或放行)防火牆將samba伺服器的共享資源cwl掛載到客戶機本地
[root@chenwanli ~]# mount -t cifs  /opt/smb/ -o username=wxl,password=123

[root@chenwanli ~]# df -h

檔案系統 容量 已用 可用 已用% 掛載點

devtmpfs 905m 0 905m 0% /dev

tmpfs 914m 140k 914m 1% /dev/shm

tmpfs 914m 8.9m 905m 1% /run

tmpfs 914m 0 914m 0% /sys/fs/cgroup

/dev/sda1 497m 119m 379m 24% /boot

18g 3.1g 15g 18% /opt/smb

//在客戶機上進入共享目錄建立新檔案
[root@chenwanli smb]# ls

[root@chenwanli smb]# touch slm

[root@chenwanli smb]# mkdir aaaa

[root@chenwanli smb]# ls

slm aaaa

/到伺服器上驗證
[root@wangxiaolan ~]# cd /opt/cwl/

[root@wangxiaolan cwl]# ls

slm aaaa

搭建sam匿名共享伺服器

服務端 wangxiaolan 172.16.30.11 客戶端 chenwanli 172.16.30.111 使用yum命令安裝samba伺服器 root wangxiaolan yum y install samba 在全域性配置中新增如下內容 root wangxiaolan vim etc...

nginx伺服器新增使用者認證

通過nginx實現web頁面的認證,需要修改nginx配置檔案,在配置檔案中新增auth語句實現使用者認證。最後使用htpasswd命令建立使用者及密碼即可。實現此案例需要按照如下步驟進行。步驟一 修改nginx配置檔案 1 修改 usr local nginx conf nginx.conf ro...

伺服器搭建 使用者管理

使用者組管理 給使用者新增sudo許可權 刪除使用者 備註 參考 whoami檢視當前登入使用者名稱 shell控制台的游標在不同使用者下是不同的.是普通管理員,是系統管理員.在ubuntu下,root使用者預設是沒有密碼的,因此也就無法使用 據說是為了安全 想用root的話,得給root使用者設定...