CentOS服务器目录通过Samba映射到Windows磁盘驱动器

一、安装Samba

[root@localhost /]# yum install samba samba-client

二、创建Samba账号

# 创建一个用户组admin
[root@localhost /]# groupadd admin
# 在用户组下创建用户
[root@localhost /]# useradd -g admin admin

三、目录授权

# 假设需要映射的目录为/home
[root@localhost home]# chmod -R 777 /home
[root@localhost home]# chown -R admin:admin /home
# 关于chown命令的使用:先用户其次才是用户组(用户:用户组)

四、修改Samba配置文件

[root@localhost /]# vi /etc/samba/smb.conf
[global]
    workgroup = SAMBA
    security = user
    # 添加下列内容
    encrypt passwords = yes
    smb passwd file = /etc/samba/smbpasswd
    # 添加结束
    passdb backend = tdbsam
    ......

# 添加下列内容
[test] #test相当于映射目录的别名,通过\\IP\test来访问
    workgroup = admin
    netbios name = admin
    path = /home
    browseable = yes
    guest ok = yes
    writeable = yes
    public = yes
    directory mask = 0777
    create mask = 0777
# 添加结束

五、设置samba用户admin的密码

[root@localhost /]# smbpasswd -a admin

六、禁用SELinux

[root@localhost /]# vi /etc/selinux/config
# 修改如下
SELINUX=disabled

七、永久关闭iptables

# 查看iptables状态
[root@localhost /]# service iptables status
# 停止iptables
[root@localhost /]# service iptables stop
# 永久关闭iptables
[root@localhost /]# chkconfig iptables off

八、启动服务

# 启动samba服务
[root@localhost /]# systemctl start smb.service
# 关闭samba服务
[root@localhost /]# systemctl stop smb.service
# 查看samba服务状态
[root@localhost /]# systemctl status smb
# 开机启动samba服务
[root@localhost /]# systemctl enable smb.service

发表评论

Free Web Hosting