[root@server ~]# useradd -r -M -s /sbin/nologin feige
[root@server ~]# su - feige
su: warning: cannot change directory to /home/feige: No such file or directory
This account is currently not available.[root@server ~]# smbpasswd -a feige
New SMB password:
Retype new SMB password:
Added user feige.
4.查看smb的配置文件
[root@server ~]# cd /etc/samba/[root@server samba]# ls
lmhosts smb.conf smb.conf.example
[root@server samba]# vim 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
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users =%S,%D%w%S
browseable = No
read only = No
inherit acls = Yes
"smb.conf"37L,706C
5.关闭防火墙并在windows上面访问smb共享账户
[root@server samba]# systemctl restart smb nmb.service
[root@server samba]# systemctl disable firewalld
[root@server samba]# systemctl stop firewalld
[root@server samba]# setenforce 0[root@server samba]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection.
SELINUXTYPE=targeted
6.检查smb.conf配置文件是否有问题
[root@server samba]# testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Weak crypto is allowed
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters[global]
printcap name = cups
security = USER
workgroup = SAMBA
idmap config *: backend = tdb
cups options = raw
[homes]
browseable = No
comment = Home Directories
inherit acls = Yes
read only = No
valid users =%S %D%w%S
[root@server samba]# useradd feige666
[root@server samba]# smbpasswd -a feige666
New SMB password:
Retype new SMB password:
Added user feige666.
8.在客户端上交互式查看服务端上的共享账户
[root@client ~]# smbclient -L 192.168.240.134-U feige666
Enter SAMBA\feige666's password:
Sharename Type Comment
--------------------
IPC$ IPC IPC Service (Samba 4.11.2)
feige666 Disk Home Directories
SMB1 disabled -- no workgroup available
9.在客户端上交互式访问服务端上的共享账户,并创建一个目录123
[root@client ~]# smbclient //192.168.240.134/feige666 -U feige666
Enter SAMBA\feige666's password:
Try "help" to get a list of possible commands.
smb: \>
smb: \> mkdir 123
smb: \> ls
. D 0 Wed Oct 1400:49:142020.. D 0 Wed Oct 1400:16:522020.mozilla DH 0 Mon Aug 3123:33:342020.bash_logout H 18 Fri Aug 3013:30:212019.bash_profile H 141 Fri Aug 3013:30:212019.bashrc H 312 Fri Aug 3013:30:212019123 D 0 Wed Oct 1400:49:14202017811456 blocks of size 1024.13020704 blocks available
10.在服务端上查看共享账户的目录是否创建成功
[root@server samba]# ls /home/feige666
123
11.在客户端上用挂载的方式将共享目录永久挂载到media里面
[root@client ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Aug 24 08:47:33 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd# units generated from this file.
#
/dev/mapper/rhel-root / xfs defaults 00
UUID=588ba91c-dfe7-423c-80c2-d7c7a0c4a790 /boot xfs defaults 00/dev/mapper/rhel-swap swap swap defaults 00//192.168.240.134/feige666/media cifs defaults,username=feige666,password=123456 0 0