centos7 samba配置

因为还是习惯用VSCode编码,但运行环境是Linux,所以决定学习一下Samba的配置,方便开发部署。

参考文章 CentOS项目实例之六--samba配置

安装Samba

yum install -y samba

yum list samba
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.163.com
 * updates: mirrors.163.com
已安装的软件包
samba.x86_64                       4.7.1-9.el7_5                        @updates

samba 3 开始security 不在支持share 共享用户

配置

我计划共享 /usr/local/src

  1. 开始配置
cd /etc/samba
cp smb.conf smb.conf.bk

vi /etc/samba/smb.conf
  1 [global]
  2     workgroup = WORKGROUP
  3     server string = Lmz Samba Server Version %v
  4     netbios name = SambaServer
  5     log file = /var/log/samba/log.%m
  6     security = user
  7     map to guest = Bad User
  8
  9 [src]
 10     comment = Public Stuff
 11     path = /usr/local/src
 12     public = no
 13     writable = yes
 14     write list = @RD
 15     valid users = @RD
  1. 创建操作系统用户
user add gavin
  1. 修改用户组
usermod -a -G RD gavin
id gavin
uid=1001(gavin) gid=1001(gavin) 组=1001(gavin),1000(RD)
  1. 创建Samba用户
smbpasswd -a gavin
  1. 修改目录权限
chown RD:RD /usr/local/src/
chmod 770 /usr/local/src/
ll -d /usr/local/src/
drwxrwx---. 15 RD   RD    200 8月  24 09:25 .
  1. 重启Samba,设置为默认启动
systemctl restart smb
systemctl enable smb
systemctl status smb
● smb.service - Samba SMB Daemon
   Loaded: loaded (/usr/lib/systemd/system/smb.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2018-08-24 08:49:23 CST; 47min ago
 Main PID: 10492 (smbd)
   Status: "smbd: ready to serve connections..."
   CGroup: /system.slice/smb.service
           ├─10492 /usr/sbin/smbd --foreground --no-process-group
           ├─10500 /usr/sbin/smbd --foreground --no-process-group
           ├─10501 /usr/sbin/smbd --foreground --no-process-group
           └─10502 /usr/sbin/smbd --foreground --no-process-group

8月 24 08:49:22 localhost.localdomain systemd[1]: Starting Samba SMB Daemon...
8月 24 08:49:23 localhost.localdomain smbd[10492]: [2018/08/24 08:49:23.3434...
8月 24 08:49:23 localhost.localdomain smbd[10492]:   STATUS=daemon 'smbd' fi...
8月 24 08:49:23 localhost.localdomain systemd[1]: Started Samba SMB Daemon.
Hint: Some lines were ellipsized, use -l to show in full.
  1. 配置windows
>net use * /del
你有以下的远程连接:
                    \\192.168.43.113\public
继续运行会取消连接。

你想继续此操作吗? (Y/N) [N]: y
命令成功完成。

>net use \\192.168.43.113 [用你的密码,不需要方括号] /U:gavin
命令成功完成。

windows 访问\192.168.43.113\src


centos7 samba配置_第1张图片
windows访问samba成功

你可能感兴趣的:(centos7 samba配置)