File Server With Samba and FTP in FreeBSD

This manual describes how to create file server, where users from can access their files with samba client and FTP server, (from windows too). In this example there are two users, testa and testu. User testa can read and write in admin (FTP only) and public directories. User testu can read and write in the public directory and can read admin directory.

In this example were used:

  • FreeBSD 7.2
  • VsFTP
  • Samba Server

Let’s Start

  1. Create Users and Directories

    1. Create Users and answer all questions

      Type in terminal

      adduser testa
      ...
      adduser testu

      File /etc /passwd should be like this

      testu:*:1004:1002:testu:/home/testu:/usr/sbin/nologin
      testa:*:1005:1003:teata:/home/testa:/usr/sbin/nologin

      Create groups named ‘all’ and ‘admin’ and edit /etc/group file like this

      all:*:1002:testa
      admin:*:1003:
    2. Create Directories
      mkdir /files
      mkdir /files/admin //Administrative access ex. for user testa
      mkdir /files/public //Public access ex. for user testu

      etc.

    3. Set permissions like this
      files# ls -all /
      dr-xr-xr-x 4 admin admin 512 Sep 18 13:11 files
      files# ls -all /files/
      drwxrwxr-x 3 admin admin 512 Oct 6 12:29 admin
      drwxrwxr-x 5 all all 512 Oct 6 12:43 public

      etc.

  2. Install vsftp FTP Server

    1. Edit Config File
      mcedit /usr/local/etc/vsftpd.conf
    2. Edit and add in vsftpd.conf
      local_umask=0002
      local_root=/files
    3. Restart FTP Server
      /usr/local/etc/rc.d/vsftpd restart
  3. Install Samba Server

    1. Edit Config File
      mcedit /usr/local/etc/smb.conf
    2. Add
      hosts allow = 192.168.0. 127.

      [admin]
         comment = Admin Files
         path = /files/admin
         public = yes
         writeable = no
         read only = yes
      [public]
         comment = Public Files
         path = /files/public
         directory mask = 0775
         create mask = 0664
         force group = all
         force user = all
         public = yes
         writeable = yes
         read only = no
    3. Restart Samba Server
      /usr/local/etc/rc.d/samba restart

If you need to add users who have administrator’s access (for access /files/*) you need to add username into /etc/group after all:*:1002:testa, another_user. In this example user testa can create delete and read in /files/*, user testu only in /files/public/*

3 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.