Installation and configuration of Samba server in virtual machine and communication with host in Win7 environment

Considering that it is troublesome to transfer files between windows and linux virtual machines, we plan to install a Samba server in the virtual machine to share files for windows. However, the installation process was unusually tortuous, so the record is as follows:

First, the installation of samba server

The normal installation process is as follows:
1. Install samba: yum install samba
  Check the samba installation status: rpm qa | grep samba (make sure the samba server has been installed normally)
2. Configure the samba service: vim /etc/samba/smb.conf
  testparm tests the samba configuration file for syntax errors
3. Add a new samba user:
  smbpasswd -a user_name Add a new samba user (provided that the user already exists in the Linux system, otherwise you need to add the user to the system first)
  smbpasswd -x user_name delete samba user
  pdbedit -L lists all samba users
4. Restart the samba service: service smb restart
Problems encountered during installation: Dependency package error Yunyun
        
I have searched online for a long time, but I have not found a suitable answer (the idea of ​​finding dependent packages is biased, because the yum command itself can automatically solve the problem of dependent packages).
After that, I used yum update command and noticed that there is such a problem,
         
Then, I realized the problem--maybe it was caused by some process files left , and there was a conflict during the reinstallation?
Anyway, since the command yum-complete-transaction is in the yum-utils package, first install yum-utils, use the command yum install yum-utils;
Then execute the command yum-complete-transaction, samba is successfully installed, and the problem is solved.
Summary: When encountering a problem, first patiently find out all the places that may cause the problem, and consider where the source of the problem is .

Second, the communication between the samba server and the host

The problem encountered is to access the shared port of samba through the win7 host running window (key: win+R), and cannot connect to samba:
        
In order to solve this problem, I have almost searched for resources on the Internet, but unfortunately there is no solution for the problem I encountered. However, this thread mentions https://www.iyunv.com/thread-70422-1-1.html . The networking configuration of the virtual machine has always been in NAT mode, and then switched to bridge mode, and the connection is indeed successful.
The problem also seems to be related to my breaking down the end goal into different steps. The final effect is to achieve win7 access to CentOS's samba in the virtual machine, but first, you can log in with the smbclient client locally in the virtual machine. If this is successful, you can further realize win7's access to samba.
However, even in a virtual machine the operation is still unsuccessful. But the advantage is that there are prompts for errors, as follows:
session setup failed: SUCCESS - 0
Therefore, through this prompt, I searched for network resources, and finally found a reference solution https://www.iyunv.com/thread-70422-1-1.html .
The new contents of the samba configuration file /etc/samba/smb.conf are as follows (simple configuration can meet the requirements):
[work_dzh] ; shared directory virtual name
    comment = DZH share dircetory ; share directory description
    path = /home/work ; the real shared directory
    browseable = yes ; directory is browseable
    writable = yes ; directory writable
    valid users = dzh ; the login user is: dzh
In addition, for easy access, the shared file work_dzh in the virtual machine can be configured as a network file,
However, in this way, the startup process of the computer is abnormally slow (this is because the computer startup process needs to load the drive Z, but because the virtual machine is not turned on, the drive Z has not been found, which takes a lot of time).

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112258&siteId=291194637