1.1. installation
1.2. Uninstall
1.3. Check the Samb version
1.4. Check and start Samba service
2.1. Create Samba access directory
2.2. Create user account
2.3. Add a user to the samba service (the user just created)
2018.12.17 Add:
New: [Linux]Samba server supports access to soft connection files and directories:https://blog.csdn.net/humanking7/article/details/85058471
apt-get install samba samba-common
# or
aptitude install -y samba
apt-get autoremove samba
method 1:
root@HP-xw4600:~# smbd --version
Version 4.3.11-Ubuntu
**Method 2: **
root@HP-xw4600:~# smbstatus
Samba version 4.3.11-Ubuntu
PID Username Group Machine Protocol Version
------------------------------------------------------------------------------
Service pid machine Connected at
-------------------------------------------------------
No locked files
Check if Samba service is running
systemctl status smbd
systemctl status nmbd
To start these two services
systemctl start smbd
systemctl start nmbd
After it starts running, smbd
will listen on ports 139
and 445
.
Create a samba access directory and increase the permissions of the directory
mkdir /srv/qfxFtp/HDD_sdb1/qfxSamba_share
chmod 777/srv/qfxFtp/HDD_sdb1/qfxSamba_share
I mounted the hard disk under the HDD_sdb1
directory, and the entire qfxFtp
directory is the directory of the FTP
server, but the permissions are read-only.
By default, Samba
sets the user to safe mode
, which means that the client must enter the user name
and password
of the shared folder.
Simply put: The added Samba user must first be a Linux user, so you have to create a new Linux user first. You can also use your original user as long as you are not afraid of leaking account information.
To add a user on Ubuntu
, please run the following command (when I add a user, for safety, the user cannot log in). Replace the user name with the user name you need. I named it qfxsamba
here (the original name was named qfxSamba
, where S
is uppercase, how to add the name is wrong, and finally look at the prompt carefully, and then I know that there is a problem with the naming , But what's wrong with the naming?)
adduser -s /sbin/nologin qfxsamba
smbpasswd -a qfxsamba #[Enter the password to access Samba,Not a qfxsamba user password]
**PS: Common methods of **smbpasswd
command:
smbpasswd -a Add users (the users to be added must be system users)
smbpasswd -d Freeze the user, that is, the user cannot log in
smbpasswd -e Restore users, unfreeze users, so that frozen users can use
smbpasswd -n Set the user's password to blank.
To write null passwords in global-true
smbpasswd -x delete user
Only one configuration file needs to be processed: /etc/samba/smb.conf
First develop a good habit of backup, and then edit with Vim
:
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
vim /etc/samba/smb.conf
The following is the part to be modified
[ global]
# Make sure that the value of the workgroup is the same as the workgroup setting of the Windows computer
workgroup = WORKGROUP
# =====================================
# add by Qfx
# =====================================
# " Qfx Share Dir"Is the folder name that will be displayed on the Windows network
# The comment is a description of the shared folder
# Can visit/srv/qfxFtp/HDD_sdb1/qfxSamba_share/table of Contents
# Can write
# Specify a valid user
[ Qfx Share Dir]
comment = Qfx share Folder
path =/srv/qfxFtp/HDD_sdb1/qfxSamba_share
writable = yes
valid users = qfxsamba
systemctl restart smbd
Suppose the IP address
of my Linux
is 10.12.55.69
Enter in the Windows file browser:
\\10.12.55.69
Then the login dialog box will pop up, enter the user name and password to log in (the password is the one set by smbpasswd -a qfxsamba
)
Possible problems
Samba
only supports NTLM
authentication, while WIN7
or VISTA
uses NTLMv2
authentication, so some settings are required. The specific settings are as follows:
Start->
run->
secpol.msc->
Local strategy->
Security Options->
Network security: LAN manager authentication level->
Send LM and NTLMv2,If negotiated, use NTLMv2(Session security&)->
Finish setting
Now the only user who can log in to the samba
server is qfxsamba
.
The following methods have not been tested:
If multiple accounts are more suitable for accessing the shared folder, please change the effective user as shown below in the /etc/samba/smb.conf
file.
valid users = user1, user2, user3
You can also use smbpasswd to set a Samba password for each user.
smbpasswd -a user1 #[Enter the password to access Samba,Not user1 user password]
# Set up
smbpasswd -a user2 #[Enter the password to access Samba,Not user2 user password]
# Set up
smbpasswd -a user3 #[Enter the password to access Samba,Not user3 user password]
# Set up
To allow a group of users to access the shared folder, use the following configuration in /etc/samba/smb.conf
.
valid users = @sambashare
Create group
groupadd sambashare
Then add the user to this group
gpasswd -a qfxsamba sambashare
gpasswd -a user1 sambashare
gpasswd -a user2 sambashare
gpasswd -a user3 sambashare
This group needs to have write access to the shared folder, which can be achieved through the following two commands.
Set sambashare
as the group owner of the shared folder:
chgrp sambashare /path/to/shared/folder -R
Write permissions granted to the group:
chmod g+w /path/to/shared/folder/-R
OK!
Above, Enjoy~
Recommended Posts