Hello there This is your first time to login from this IP. Have fun with Enterprise Q&A
0 投票
分类:Other related | 用户:

http://www.jebbs.co/2015/06/09/openwrt-samba/

OpenWrt Samba 共享配置

发布于 2015年6月9日 作者 jebbs

安装Samba软件以及Web配置界面


1

2

opkg update

opkg install luci-app-samba

安装“luci-app-samba”时会自动安装他的依赖项,“samba36-server”,安装好后,如果在WEB界面中没有找到共享的配置,可以重启路由,或者通过以下命令清除界面缓存:

1

rm /tmp/luci-indexcache

修改配置模板


由于OpenWRT添加用户需要额外安装shadow软件包,而OpenWRT本身又不太建议这样做,所以直接以root配置,因此不能禁用root。
编辑 /etc/samba/smb.conf.template,注释掉 invalid users = root 即可。这一步也可以在Web界面下进行(建议)。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

[global]

    netbios name = |NAME|

    display charset = |CHARSET|

    interfaces = |INTERFACES|

    server string = |DESCRIPTION|

    unix charset = |CHARSET|

    workgroup = |WORKGROUP|

    browseable = yes

    deadtime = 30

    domain master = yes

    encrypt passwords = true

    enable core files = no

    guest account = nobody

    guest ok = yes

    #invalid users = root

    local master = yes

    load printers = no

    map to guest = Bad User

    max protocol = SMB2

    min receivefile size = 16384

    null passwords = yes

    obey pam restrictions = yes

    os level = 20

    passdb backend = smbpasswd

    preferred master = yes

    printable = no

    security = user

    smb encrypt = disabled

    smb passwd file = /etc/samba/smbpasswd

    socket options = TCP_NODELAY IPTOS_LOWDELAY

    syslog = 2

    use sendfile = yes

    writeable = yes

用户设置


添加root用户并设置密码。

1

2

touch /etc/samba/smbpasswd

smbpasswd -a root

如果要修改用户密码


1

smbpasswd root XXXX

配置共享


点击“服务”下的“网络共享”菜单,在出现的界面中配置即可。

手工配置共享


修改/etc/config/samba 文件,添加下面内容以增加共享文件夹,内容根据实际情况修改。这一步也可以在Web界面下进行(建议)。

1

2

3

4

5

6

7

8

config sambashare

    option name 'test'

    option path '/root'

    option users 'root'

    option read_only 'no'

    option guest_ok 'no'

    option create_mask '700'

    option dir_mask '700'

/etc/samba/smb.conf 配置文件是根据 /etc/config/samba 文件和 /etc/samba/samba.conf.template 文件自动生成的,因此手工修改这个文件,也可以配置共享,但会在重启服务时被覆盖(即丢失)

1

2

3

4

5

6

7

[test]

    path = /root

    valid users = root

    read only = no

    guest ok = no

    create mask = 700

    directory mask = 700

启动Samba服务


1

2

/etc/init.d/samba restart     #重启Samba服务

/etc/init.d/samba enable     #允许开机自启动

2 个回答

0 投票
用户:
root@XiaoQiang:/etc/samba/smb.conf.template

因为smb.conf是自动生成,重启会重置,直接修改smb.conf.template添加即可

[pi2]
  path = /userdisk/data/pi2
  read only = no
  guest ok = yes
  create mask = 0666
  directory mask = 0777
  browseable = yes
  force user = root
0 投票
用户:
sudo mount -t cifs //192.168.31.1/pi2 /var/www/video.shishine.com/ -o guest

挂载共享文件,
Welcome to Memo QA
欢迎来到Memo快速问答

分类

...