Through Samba, we can mount folders from Linux to Windows. After deploying Samba on a Linux virtual machine, I can use the remote compilation plugin I wrote a few days ago (sublimeRemoteCompile) to write code on Windows! It’s quite enjoyable. Today, I will briefly record how to configure Samba sharing on the server for friends with similar needs.
Note: Do not use NAT for VMware virtual machines; choose bridge mode, otherwise, it might not be on the same network segment as the host, and SSH may fail to connect.
Installation
1 | sudo apt-get install samba |
Edit the configuration file
First, back up the default configuration file:
1 | sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak |
Then create a smb.conf
file under /etc/samba
:
1 | sudo nano /etc/samba/smb.conf |
Fill in the following configuration (a configuration that requires account login and is readable and writable):
1 | [global] |
Regarding those modes (create/force create/directory/force directory) permissions, if it’s only for personal use, it’s recommended to set it to 777 because if set to 755, the following error might occur:
1 | /usr/bin/ld: cannot open output file 1: Permission denied |
For the above smb.conf
, you need to create the folder at the path
specified.
Change the permissions of the path directory to 755
:
1 | sudo chmod -R 755 /home/visionsmile |
Create a samba account (Note: this account must exist in your local system, for example, root):
1 | pdbedit -a root |
You will be prompted to enter the password for the samba account.
Check the samba accounts:
1 | pdbedit -L |
Then you can start samba:
1 | # Start |
Startup Errors
If you encounter the following issues when starting:
This situation arises because
- The operating system is Debian 8 or higher, and Samba Server version is 4.2 or higher.
- Samba 4 does not support
security = share
; you can either remove it or change it tosecurity = user
.
Mapping to Local on Windows
Open My Computer -> Map Network Drive.
After entering the samba account password you created, you can see the shared folder: