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

      1
      adduser testa<br>...<br>adduser testu

      File /etc /passwd should be like this

      1
      testu:*:1004:1002:testu:/home/testu:/usr/sbin/nologin<br>testa:*:1005:1003:teata:/home/testa:/usr/sbin/nologin

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

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

      etc.

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

      etc.

  2. Install vsftp FTP Server

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

    1. Edit Config File
      1
      mcedit /usr/local/etc/smb.conf
    2. Add
      1
      hosts allow = 192.168.0. 127.<br><br>[admin]<br>   comment = Admin Files<br>   path = /files/admin<br>   public = yes<br>   writeable = no<br>   read only = yes<br>[public]<br>   comment = Public Files<br>   path = /files/public<br>   directory mask = 0775<br>   create mask = 0664<br>   force group = all<br>   force user = all<br>   public = yes<br>   writeable = yes<br>   read only = no
    3. Restart Samba Server
      1
      /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.