centos安装samba

centos安装samba

1、查看当前版本:

$ rpm -qa | grep samba

2、卸载

$ yum remove -y samba

3、安装

$ yum install -y samba

4、创建一个共享目录/home/samba:

$ cd /home
$ mkdir samba

5、创建一个samba登陆用户:

$ useradd samba //为系统创建一个samba
$ passwd samba //为用户设置一个密码

6、创建一个samba用户:

$ smbpasswd -a samba //创建samba客户端用户

7、配置samba:

$ cd /etc/samba
$ ls
$ cp smb.conf smb.conf.back
$ vim smb.conf

修改用户组,看你的电脑上是什么用户组:

[global]

# ----------------------- Network Related Options -------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to the hostname
#
# Interfaces lets you configure Samba to use multiple interfaces
# If you have multiple network interfaces then you can list the ones
# you want to listen on (never omit localhost)
#
# Hosts Allow/Hosts Deny lets you restrict who can connect, and you can
# specifiy it as a per share option as well
#
        workgroup = WORKGROUP
        server string = Samba Server Version %v

;       netbios name = MYSERVER

;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24 
;       hosts allow = 127. 192.168.12. 192.168.13.

然后,在最后一行添加:

       [samba]
       comment = samba
       path = /home/samba
       public = yes
       writable = yes
       valid users = samba

8、配置生效,重启samba服务:

chkconfig smb on
chkconfig nmb on
service smb start
service nmb start

9、配置防火墙开放端口:

$ cd /etc/sysconfig
$ ls
$ vim iptables

在最后一行添加:

-I INPUT -p tcp --dport 137 -j ACCEPT
-I INPUT -p udp --dport 137 -j ACCEPT
-I INPUT -p tcp --dport 138 -j ACCEPT
-I INPUT -p udp --dport 138 -j ACCEPT
-I INPUT -p tcp --dport 139 -j ACCEPT
-I INPUT -p udp --dport 139 -j ACCEPT
-I INPUT -p tcp --dport 445 -j ACCEPT
-I INPUT -p udp --dport 445 -j ACCEPT

重启防火墙:

$ service iptables restart

10、连接测试:

在你的电脑上 开始->运行 输入你的服务器ip地址:

等待一会:

输入你的samba账号密码:

 

然后可以直接拖到你的sublime直接可以编辑保存!

 如果windows下登录samba服务器后无法访问linux下共享目录,提示没有权限

1、确保linux下防火墙关闭或者是开放共享目录权限

2、确保samba服务器配置文件smb.conf设置没有问题,可网上查阅资料看配置办法  

3、确保setlinux关闭,可以用setenforce 0命令执行。 默认的,SELinux禁止网络上对Samba服务器上的共享目录进行写操作,即使你在smb.conf中允许了这项操作。

# setenforce 0

 /usr/bin/setenforce 修改SELinux的实时运行模式  

setenforce 1 设置SELinux 成为enforcing模式

setenforce 0 设置SELinux 成为permissive模式  

如果要彻底禁用SELinux 需要在/etc/sysconfig/selinux中设置参数selinux=0 ,或者在/etc/grub.conf中添加这个参数

  /usr/bin/setstatus -v

posted @ 2017-09-22 09:58  丶老中医  阅读(183)  评论(0编辑  收藏  举报
一切已经开始©2018 丶老中医