linux网络服务[samba信息服务块]——————虚拟用户、挂载网络驱动器

文章目录

  • 1. 虚拟用户
  • 2. 挂载网络驱动器
    • 2.1 临时挂载:
    • 2.2 永久挂载

1. 虚拟用户

1)修改别名用户配置文件:

[root@smb-server ~]# vim /etc/samba/smbusers

liu = l

2)主配置文件调用这个文件:(最好写入全局配置中)

[root@smb-server ~]# vim /etc/samba/smb.conf

[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw
        username map = /etc/samba/smbusers # 写入全局配置中

3)重启服务:

[root@smb-server ~]# systemctl restart smb.service

4)客户端测试l别名(登录成功):

[root@client1 ~]# smbclient -U l  //172.25.5.10/testsong
Enter l's password: 
Domain=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4]
smb: \> ls
  .                                   D        0  Sun Aug 23 15:58:46 2020
  ..                                 DR        0  Sun Aug 23 15:10:01 2020
  initial-setup-ks.cfg                N     2143  Sun Aug 23 15:58:46 2020

		4597760 blocks of size 1024. 1434824 blocks available
smb: \>

5)没有的别名进行测试(登录失败):

[root@client1 ~]# smbclient -U s  //172.25.5.10/testsong
Enter s's password: 
session setup failed: NT_STATUS_LOGON_FAILURE

2. 挂载网络驱动器

samba的默认文件系统就是cifs文件系统。

2.1 临时挂载:

1)客户端挂载:

[root@client1 ~]# mount -t cifs -o username=liu,password=123456 //172.25.5.10/testsong /mnt

2)写入文件:

[root@client1 mnt]# vim test

liuyaowen

3)服务端查看:写入的文件,和内容都在服务器上存在以liu用户建立

[root@smb-server testsong]# ls
initial-setup-ks.cfg  test
[root@smb-server testsong]# ll
total 8
-rw-r--r-- 1 liu liu 2143 Aug 23 15:58 initial-setup-ks.cfg
-rw-r--r-- 1 liu liu   10 Aug 23 16:21 test
[root@smb-server testsong]# cat test
liuyaowen

4)客户端解挂:(解挂成功)

[root@client1 ~]# umount /mnt
[root@client1 ~]# df
Filesystem            1K-blocks    Used Available Use% Mounted on
/dev/mapper/rhel-root   4597760 3182144   1415616  70% /
devtmpfs                 492416       0    492416   0% /dev
tmpfs                    508264     144    508120   1% /dev/shm
tmpfs                    508264   13520    494744   3% /run
tmpfs                    508264       0    508264   0% /sys/fs/cgroup
/dev/sda1                201380  153928     47452  77% /boot
tmpfs                    101656       4    101652   1% /run/user/42
tmpfs                    101656      12    101644   1% /run/user/0

2.2 永久挂载

1)客户端写入开机自动挂载文件:

[root@client1 ~]# vim /etc/fstab

//172.25.5.10/testsong  /mnt    cifs    defaults,username=liu,password=123456   0 0

2)客户端自动挂载:(成功)

[root@client1 ~]# mount -a # 扫描/etc/fstab文件将没有挂载成功的进行挂载
[root@client1 ~]# df
Filesystem             1K-blocks    Used Available Use% Mounted on
/dev/mapper/rhel-root    4597760 3182136   1415624  70% /
devtmpfs                  492416       0    492416   0% /dev
tmpfs                     508264     144    508120   1% /dev/shm
tmpfs                     508264   13520    494744   3% /run
tmpfs                     508264       0    508264   0% /sys/fs/cgroup
/dev/sda1                 201380  153928     47452  77% /boot
tmpfs                     101656       4    101652   1% /run/user/42
tmpfs                     101656      12    101644   1% /run/user/0
//172.25.5.10/testsong   4597760 3162904   1434856  69% /mnt

你可能感兴趣的:(网络,linux,samba,centos,运维)