I installed Linux (Ubuntu 20.04.1) on Windows using virtualbox, so I tried to build a file server. It is a memo of.
$sudo mkdir /home/share
$sudo chmod 0777 /home/share
I created a share directory under home and granted access to that directory. Share the contents of this directory. (The name is arbitrary, please decide the share part as you like)
mkdir → create directory chmod → Change access authority
$ sudo apt-get -y install samba
$ sudo vim /etc/samba/smb.conf
Open it with the above command and edit smb.conf. I think there is the following description on the 22nd line.
smb.conf
#======================= Global Settings =======================
[global]
## Browsing/Identification ###
Add the following description.
unix charset = UTF-8
dos charset = CP932
I will make it like this.
smb.conf
#======================= Global Settings =======================
[global]
unix charset = UTF-8
dos charset = CP932
## Browsing/Identification ###
Edit the following if necessary. I didn't need to edit it.
smb.conf
#Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
Write the value of the Winodws workgroup in WORKGROUP
workgroup = Control Panel-> System and Security-> System -> Computer name, domain and workgroup settings
There is the following description near the 38th line.
smb.conf
#### Networking ###
This item seems to be used to limit the connection source IP address. I didn't edit this time.
Add the following to the end of the file:
smb.conf
[Share]
path = /home/share
writable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777
For [Share], give any name to the folder name for sharing. For path, enter the path of the directory you want to share first.
$ sudo systemctl restart smbd
$ sudo systemctl enable smbd
Check the server name on linux.
$ hostname
server name
Open Explorer in Windows and from Map Network Drive Click Map Network Drive.
In the folder field, specify "\ server name \ shared folder name".
The server name was confirmed on Linux earlier. The folder name is the [Share] part you specified earlier. (In this case, share)
The user authentication screen will appear and you can enter it. You should now be able to access the file.
This is a method to restrict user access in groups.
$ sudo groupadd share
The share group has been created.
Edit what you added at the end of smb.conf.
smb.conf
[Share]
path = /home/share
writable = yes
guest ok = no
create mode = 0777
directory mode = 0777
valid users = @share
Specify the group name that can be authenticated by valid users. This time, users who belong to the share group can access it.
Only if you want to create a new user. Even users who have made it from the beginning are okay.
$sudo useradd -m username
$sudo passwd username
After this, enter the password twice and the user will be created. Users should have the same name. A home directory is created by adding the useradd option -m. (-m is not necessary)
$ sudo usermod -aG share username
The user can now be registered in the group.
$ sudo pdbedit -a username
Enter the password twice and you're done. (I was able to access it with smbpasswd instead of pdbedit.)
Now you can restrict access by authentication when accessing from Windows.
https://qiita.com/k-Mata/items/8bee9e02e74565b6c147 https://qiita.com/msrks/items/1385cf13258dd1a0da08 https://www.server-world.info/query?os=Ubuntu_16.04&p=samba https://linuxfan.info/ip-address https://www.server-world.info/query?os=Ubuntu_18.04&p=samba&f=2 https://renoji.com/IT.php?Contents=OS_CentOS/Server_File/Samba_UserRegistration.html https://qiita.com/orangain/items/056db6ffc16d765a8187 https://eng-entrance.com/linux-user-add
Recommended Posts