Logic will get you from A to B. Imagination will take you everywhere, Albert Einstein
Turnkey Linux is an open source project developing a free virtual appliance library that features the very best server-oriented open source software. TurnKey File Server is a relatively easy to use file server that combines Windows-compatible network file sharing with a web based file manager.
Download the template. In Proxmox’s web interface, click on your local storage LVM (Logical Volume Manager, your Proxmox storage management system that allows you to create, resize, and manage logical volumes on your physical storage devices, e.g., local(myserver)), go to CT Templates, click on Templates, select debian-12-turnkey-fileserver···.tar.gz, and download it.
Create the LXC Container. Go to your Proxmox node (e.g., Node myserver), and click create CT button:
Turnkey Linux Fileserver. First Configuration. In your Proxmox web interface, select your new LXC container under your Node (e.g., myserver, CT 100), Console, click Start now(if you did not click on Start after created), and provide the credentials that you specify earlier. You will be prompted for a new password for the Samba Root Account. This is different from the Linux’s root account for your container! You could skip any additional optional configurations except be sure to click Install to install all security updates.
Access webmin. Open your favorite browser and point your browser to: [HTTPS:] + dirIP (your container’s static IP address) + “:” + [12321], so you get access to your Webmin System Administration UI.
Login. Go to Webmin and ignore SSL browser warning (Advanced…, Accept the Risk and continue): browsers don’t like self-signed SSL certificates, but this is the only kind that can be generated automatically. Type in the root and password that you created earlier. This the is Linux root account in your container (not the Samba root account).
Create a New Linux User. Under System, select Users and Groups, click Create a New User (e.g., nmaximo7), fill in your desired username and password, leave every else as default, and press Create.
Create a New Group. Still under User and Groups, click on the Local Groups tab, click Create a New Group. Write a Group Name (e.g., family), select its Members (add the newly created user(s), e.g., nmaximo7), and hit Create. Groups make it easy to manage permissions of files and directories because you do so in the group level.
Change Ownership and Permissions of Your Shared Directory. Go to Tools, File Manager in Webmin. Navigate go to your second disk or previous Samba share that you created when you were creating the container (e.g., /mnt/mydata), click on Tools, Change ownership, so we change the ownership of our share to our user (e.g., nmaximo7), group (e.g., family), and typically recursive (so subfolders and files also change), press Change for these changes to make effect. Besides, Tools, Change permissions, and you will typically want 775: Owner (7 -nmaximo7- Read, Write, Execute), Group (7 -family- Read, Write, Execute), Others (5, Read, NO Write, Execute)-
Confirm Samba Users. In Servers, Samba Windows File Sharing Select all the predefined Samba shares (homes, cdrom, storage), and press on Deleted Selected Shares. Then, select Convert Users to synchronize the Linux user and Samba users. In Unix user to covert, select Only linux users or UID ranges:YOUR-USER (e.g., nmaximo7), then Use this pasword. type in your password, click on Convert Users. This Linux user is now a Sambar user, too. Selecting Samba Users you should see these new linux users as Samba users, too.
Remaining in Servers, Samba Windows File Sharing, let’s create a new share by click on Create a new file share: Share name (e.g., homedata, the name that it appears to the end-user for the share), Directory to share (the resource’s path that you want to share, e.g., /mnt/mydata), Create with owner (e.g., nmaximo7) and permission (755). Click on the share to select, press on Security and Access Control and make sure that Writable is enable (yes) (we want to be able to read and write in the Share), then Save, Return to share list, Restart Samba Server to force the current configuration to be applied.
If you are using NixOS, install cifs-utils.
Create a local directory where you want to mount the Samba share, e.g., sudo mkdir -p ~/fileserver
Mounting the Share (Temporary Mount): You can use the mount.cifs command to mount the share temporarily, sudo mount.cifs //192.168.1.15/mydata ~/fileserver -o username=YOUR-SAMBA-USER=YOUR-SAMBA-PASSWORD,vers=3.0
, e.g., sudo mount.cifs //192.168.1.15/homedata ~/fileserver -o username=YOUR-SAMBA-USER,password=YOUR-SAMBA-PASSWORD,vers=3.0
where:
Alternatively, sudo mount.cifs //192.168.1.15/homedata ~/fileserver -o username=YOUR-SAMBA-USER,password=YOUR-SAMBA-PASSWORD,vers=3.0,uid=$(id -u),gid=$(id -g)
//192.168.1.15/homedata /home/YOUR-SAMBA-USER/fileserver cifs username=YOUR-SAMBA-USER,password=YOUR-SAMBA-PASSWORD,vers=3.0,uid=$(id -u),gid=$(id -g) 0 0
mount -a # Test the mount
In NixOS, add the following configuration to your configuration.nix file:
fileSystems."/home/YOUR-SAMBA-USER/fileserver" = {
device = "//192.168.1.15/homedata";
fsType = "cifs";
options = [
"username=YOUR-SAMBA-USER"
"password=YOUR-SAMBA-PASSWORD"
"vers=3.0"
"uid=1000"
"gid=1000"
"rw" # Ensure read-write access
];
};
sudo mount.cifs //192.168.1.15/homedata /mnt/fileserver -o username=nmaximo7,password=MyPASSWORD,vers=3.0
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) and kernel log messages (dmesg)
Ensure that the Samba user (nmaximo7) exists and has the correct password.In the Turnkey Linux Fileserver container, check the Samba users: pdbedit -L
(it will list all Samba users).
Add the user to the Samba database:smbpasswd -a nmaximo7
. Besides, run smbpasswd -e nmaximo7
to make sure the user is enabled in the local smbpasswd file.
Verify Share Permissions. In the Webmin UI, go to Servers, Samba Windows File Sharing. Select the share (homedata) and click Security and Access Control. Ensure that: Writable is set to Yes, Valid Users includes nmaximo7, and Valid Groups includes the group family.
In the Turnkey Linux Fileserver container:
# Ensure that the directory being shared (/mnt/mydata) has the correct ownership and permissions:
chown -R nmaximo7:family /mnt/mydata
root@filemanager /mnt# ls -la
drwxr-xr-x 2 nmaximo7 family 2 Jan 15 01:16 mydata
root@filemanager /mnt# ^C
# 755, Owner nmaximo7, Group: family
nano /etc/samba/smb.conf
[homedata]
path = /mnt/mydata
read only = no
writeable = yes
valid users = nmaximo7
create mask = 0775
directory mask = 0775
# Restart the Samba service to apply changes
systemctl restart smbd
apt update && apt install smbclient
# Test access to the share
smbclient //localhost/homedata -U nmaximo7