RSS

Tag Archives: share folder

TP-Link TL-WR1043ND – Openwrt – Ch07_Samba_file_server

0) Briefing

  • Why Samba not NFS? In simple answer: Password protected.
  • You might want to get:
    • USB external storage (Visit Ch05 to see how). Router has limited internal memory, so not much fun to have a share such a small space. But of course, I cannot stop you!
  • What next
    • Install Samba server ( 1992 Byte in size )
    • (Optional) Install luci-app-samba webpage app ( 92 Byte in size )

——————————————————————————–

1) Install Samba server software

  • Open up your favorite terminal and login into the router
    ssh root@192.168.1.1
  • These commands will update database:
    opkg update
  • Install Samba server (1992 Byte in size):
    opkg install samba36-server
  • If you want to set your Samba via web interface, install (92 Byte in size):
    opkg install luci-app-samba

——————————————————————————–

2) Add a user

  • You do not want everyone connected to your network will be able to see your files, so you need some kind of security to Samba. To have Samba secure, you need to have Samba User Account. To have Samba User Account, you need to have Linux system user account.

2.1) Setup new Linux system group for users account

  • To add new group, edit the following file:
    vim /etc/group
  • Add the following line

    john:x:1001

    1. First field : group_name = john
    2. Second field : group_password = x (I don’t think you can setup any)
    3. Third field : group_id = assign a unique number between 1000 & 65534

2.2) Setup new Linux system user account

  • To add new user account, edit the following file:
    vim /etc/passwd
  • Add the following line

    john:x:1001:1001:John Watson:/var:/bin/false

    1. First field : user_name = john
    2. Second field : user_password = x (Password store in somewhere else)
    3. Third field : user_id = assign a unique number between 1000 & 65534 
    4. Forth field : group_id = the group id you have set above
    5. Fifth field : user_info = can be lots of things, Google yourself.
    6. Sixth field : user_home_directory
    7. Seventh field : user_login_startup_program = first program auto startup when login. Usually is a command shell, now we don’t start anything

2.3) Setup user password:

  • To setup user password:
    passwd john

2.4) Setup a Samba user:

  • To setup a Samba user:
    smbpasswd -a john

——————————————————————————–

3) Samba config

  • Please note :

    Do NOT edit /etc/samba/smb.conf , it is a automatically generated file

3.1) Samba global config

  • Edit the following file:
    vi /etc/samba/smb.conf.template
  • Do not change anything between “|”
  • The only settings I changed:

    null passwords = no

3.2) Add a share folder:

  • I have setup two type of share folders, one is public read/write allowed, the other one is user login required.
  • Edit the following file:
    vi /etc/config/samba
  • Here is my /etc/config/samba details:

    config samba
    option workgroup ‘WORKGROUP’
    option name ‘OpenWRT Samba’
    option description ‘OpenWRT share folder’
    option homes ‘0’

    config sambashare
    option name ‘Pubilc’
    option path ‘/mnt/shares/public’
    option read_only ‘no’
    option guest_ok ‘yes’
    option create_mask ‘0666’
    option dir_mask ‘0666’

    config sambashare
    option name ‘Private’
    option path ‘/mnt/shares/private’
    option read_only ‘no’
    option guest_ok ‘no’
    option create_mask ‘0600’
    option dir_mask ‘0600’

3.3) Start Samba and set as service:

  • Enable Samba to startup itself at boot, and start the service now:
    /etc/init.d/samba enable
    /etc/init.d/samba start

——————————————————————————–

Appendix : References

 
2 Comments

Posted by on May 10, 2013 in Networking, Router

 

Tags: , , , , , , , , ,

 
%d bloggers like this: