Ubuntu安装配置samba

1、安装samba服务

     sudo apt-get install samba

 

2、添加samba用户

    sudo useradd username

    编辑用户密码
    sudo smbpasswd -a username
    删除用户
    sudo smbpasswd -x username 

 

3、修改smb.conf配置文件

     sudo vim /etc/samba/smb.conf

  在最后添加如下内容:

  [Share]
  comment = Share Folder
  path = /home/Jacky/Desktop/samba
  browseable = yes
  writable = yes

 

4、重新启动samba服务

     sudo /etc/init.d/samba restart

 

5、在windows中访问samba服务器

 

注意:

1)、关于selinux,请关闭selinux,在/etc/selinux/config中设置selinux为disabled。

2)、关于firewall设定:

详细可参考samba官网:http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/securing-samba.html#firewallports

Using a Firewall

Many people use a firewall to deny access to services they do not want exposed outside their network. This can be a good idea, although I recommend using it in conjunction with the above methods so you are protected even if your firewall is not active for some reason.

If you are setting up a firewall, you need to know what TCP and UDP ports to allow and block. Samba uses the following:

Port 135/TCP - used by smbd
Port 137/UDP - used by nmbd
Port 138/UDP - used by nmbd
Port 139/TCP - used by smbd
Port 445/TCP - used by smbd

The last one is important because many older firewall setups may not be aware of it, given that this port was only added to the protocol in recent years.

When configuring a firewall, the high order ports (1024-65535) are often used for outgoing connections and therefore should be permitted through the firewall. It is prudent to block incoming packets on the high order ports except for established connections.

 

 

修改/etc/sysconfig/iptables

 

 

-A INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT

-A INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

 

(说明:在httpd服务中,需开启80端口,开启方法添加如下一行:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT)

 

重启防火墙服务

service iptables restart

或/etc/rc.d/init.d/iptables restart

 

重启samba服务

/etc/rc.d/init.d/smb restart

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值