码迷,mamicode.com
首页 > 其他好文 > 详细

共享一个目录,使用用户名和密码登录后才可以访问,要求可以读写

时间:2017-06-20 14:56:07      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:密码   img   use   网上邻居   ken   lin   div   ring   blog   

1、服务端配置

[root@localhost ~]# yum install -y samba samba-client    # 安装 Samba
[root@localhost ~]# vim /etc/samba/smb.conf              # 修改配置文件
[global]
    workgroup = WORKGROUP                                # 这里要与 Windows 的工作组一致
    server string = Samba Server Version %v    
    security = user                                      # 安全级别为 user ,即需要账号密码才能登录
    passdb backend = tdbsam    
    load printers = yes    
    cups options = raw

[test]                                                   # 共享名
    comment = share all                                  # 描述信息,方便系统管理员查看
    path = /tmp/sambadir                                 # 共享的目录
    browseable = yes                                     # 共享的目录是否可见
    public = yes                                         # 共享的目录是否显示在网上邻居
    writable = yes                                       # 是否可写
[root@localhost ~]# mkdir /tmp/sambadir                  # 创建共享的目录
[root@localhost ~]# useradd smbuser1 # 创建系统用户
[root@localhost ~]# pdbedit -a smbuser1 # 将系统用户添加到 Samba 库并设置密码,使用该用户来访问 Samba [root@localhost ~]# /etc/init.d/smb start # 启动 Samba

 

2、Windows 客户端访问

技术分享

 

3、Linux 客户端访问(可以直接访问也可以通过挂载的方式来访问)

[root@localhost ~]# yum install -y samba-client                    # 安装 Samba 客户端软件包
[root@localhost ~]# smbclient -Usmbuser1 //192.168.123.102/test    # test 是共享名
Enter smbuser1‘s password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.23-43.el6_9] 
smb: \>
[root@localhost ~]# yum install -y cifs-utils    # cifs 是一种通用的网络文件系统
[root@localhost ~]# mount -t cifs -o username=user1,password=123 //192.168.1.111/test /opt    # 挂载到 /opt 目录
Password:    

 

 

 

 

 

 

         

 

共享一个目录,使用用户名和密码登录后才可以访问,要求可以读写

标签:密码   img   use   网上邻居   ken   lin   div   ring   blog   

原文地址:http://www.cnblogs.com/pzk7788/p/7053754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!