Samba是在Linux和UNIX系统上实现SMB协议的一个免费软件,由服务器及客户端程序构成。
<h3>安装</h3>

<span class="comment">yum</span> <span class="literal">-</span><span class="comment">y</span> <span class="comment">install</span> <span class="comment">samba</span>

<h3>配置</h3>
samba配置文件在/etc/samba/smb.conf,修改这个配置文件在最后加入下面的配置:

<span class="title">[linux_share]</span>
<span class="setting">path=<span class="value">/home/share</span></span>
<span class="setting">writable = <span class="value"><span class="keyword">yes</span></span></span>
<span class="setting">public=<span class="value"><span class="keyword">yes</span></span></span>
  • linux_share:共享名称,可以随便写
  • path:共享文件夹的路径
  • writable:是否可写

注意下面的配置:

[<span class="keyword">global</span>]
        workgroup = SAMBA
        security = user

如果security = user,那么需要输入用户名和密码才可以访问,这样相对叫安全,因此我们需要为samba创建一个用户。

<span class="preprocessor">#创建系统用户share</span>
<span class="title">useradd</span> share
<span class="preprocessor">#创建samba用户</span>
<span class="title">smbpasswd</span> -a share

请注意为共享文件赋予share用户权限。
<h3>防火墙放行端口</h3>

<span class="comment">vi</span> <span class="comment">/etc/sysconfig/iptables</span>
<span class="literal">-</span><span class="comment">A</span> <span class="comment">INPUT</span> <span class="literal">-</span><span class="comment">p</span> <span class="comment">tcp</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">state</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">state</span> <span class="comment">NEW</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">tcp</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">dport</span> <span class="comment">139</span> <span class="literal">-</span><span class="comment">j</span> <span class="comment">ACCEPT</span>
<span class="literal">-</span><span class="comment">A</span> <span class="comment">INPUT</span> <span class="literal">-</span><span class="comment">p</span> <span class="comment">tcp</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">state</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">state</span> <span class="comment">NEW</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">tcp</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">dport</span> <span class="comment">445</span> <span class="literal">-</span><span class="comment">j</span> <span class="comment">ACCEPT</span>
<span class="literal">-</span><span class="comment">A</span> <span class="comment">INPUT</span> <span class="literal">-</span><span class="comment">p</span> <span class="comment">udp</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">state</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">state</span> <span class="comment">NEW</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">udp</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">dport</span> <span class="comment">137</span> <span class="literal">-</span><span class="comment">j</span> <span class="comment">ACCEPT</span>
<span class="literal">-</span><span class="comment">A</span> <span class="comment">INPUT</span> <span class="literal">-</span><span class="comment">p</span> <span class="comment">udp</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">state</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">state</span> <span class="comment">NEW</span> <span class="literal">-</span><span class="comment">m</span> <span class="comment">udp</span> <span class="literal">-</span><span class="literal">-</span><span class="comment">dport</span> <span class="comment">138</span> <span class="literal">-</span><span class="comment">j</span> <span class="comment">ACCEPT</span>
<span class="comment">#重载Iptables</span>
<span class="comment">service</span> <span class="comment">iptables</span> <span class="comment">restart</span>

<h3>启动samba服务</h3>

<span class="title">service</span> smb start
Last modification:August 7th, 2019 at 11:36 am
如果觉得我的文章对你有用,请随意赞赏