SMB服务实现Windows与Linux之间文件共享

This utility provides command-line access to SMB resources,much like an FTP client
This eliminates the need to install the NFS servers on the PC clients and to enhance the file sharing between SMB servers and AIX through
When there is breakdown in the one of the connections ,the SMB switches (sometimes manually) to another service provider

今天上午上了云计算,讲到了文件共享,那就搭建一个文件共享smb服务来实现Windows与Linux系统之间的文件共享

理论部分
A. 在Samba文件共享服务
a. 1987年微软公司和英特尔公司共同制定了SMB(Server Messages Block,服务器信息块协议),旨在解决局域网内文件或打印机等资源的共享问题,使得主机之间共享文件变得越来越简单
b. 1991年在读大学生Tridgwell为了解决Linux系统与Windows系统之间的文件共享问题,基于SMB协议开发出了SMBServer服务程序
c. SMBServer服务程序是一款开源的文件共享软件,经过简单的配置就能够实现Linux系统与Windows系统之间的文件共享
d. Samba服务程序现在已经成为了Linux系统与Windows系统之间共享文件的最最佳选择
试验部分:
安装samba配置:
0. 光驱挂载到目录
1. yum –y install samba
2. mkdir /home/database 创建共享目录
3. 由于smb.conf配置文件参数众多,所以重命名参数文件为smb.conf_bak并利用重定向技术,管道符对参数文件中需要用到的参数进行提取cat /etc/samba/smb.conf.bak | grep –v “#” | grep – v “;” | grep –v“^$” > /etc/samba/smb.conf
4.Vim smb.conf

  1. Service smb restart

  2. 创建用于访问共享资源的账户信息
    Pdbedit –a –u zjx
    Chown –RF zjx:zjx /home/database(为何要这样设置,留个悬念,不过多解释)
    CentOS7使用//Semanage fcontext –a –t samba_share_t home/database
    //Restorecon –Rv /home/database
    设置SELinux服务于策略,使其允许通过Samba服务程序访问普通用户家目录
    //Getsebool –a | grep samba
    //Setsebool –P samba_enable_home_dirs on

  3. 测试共享前提是windows7能够与linux通信

  4. 重启smb服务 service smb restart并停止iptables防火墙 service iptables stop
    // Systemctl restart smb
    // Systemctl enable smb
    SMB服务实现Windows与Linux之间文件共享

SMB服务实现Windows与Linux之间文件共享

SMB服务实现Windows与Linux之间文件共享
SMB服务实现Windows与Linux之间文件共享

当你看到下面这个页面的时候表示你已经成功一大半

SMB服务实现Windows与Linux之间文件共享

见下图,如何解决?是锻炼你排错能力的时候了

SMB服务实现Windows与Linux之间文件共享

解决:顾名思义既然是权限不足,那就更改权限喽,就给该共享文件夹的拥有用户,所属组,普通用户都赋予了最大权限执行命令chmod 777 /home/database,还是不行,原来是SELinux安全子系统搞的鬼, 强制开启模式是 enforcing,而 permissive 是只发出警告而不强制拦截的模式

SMB服务实现Windows与Linux之间文件共享