Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

CentOS7 samba and windows map network drives

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Step 1: install the samba service

"yum install samba

Step 2: start the samba service

"systemctl start smb

View the status of samba

"systemctl status smb

When you see Active, it means it's running.

Step 3: turn off the firewall

"systemctl stop firewalld.service / / stop service

"systemctl disable firewalld.service / / shutdown, boot

At the same time, there is this step.

Set SELINUX=disabled (computer needs to be restarted)

Set SELINUX=disabled in the vi / etc/selinux/config file, and then restart the server.

Step 4: you need to add a user to access the file

"useradd lcd / / add users

"passwd lcd / / change password

Create a samba user

"smbpasswd-a lcd

Step 5: modify the configuration file of samba

"vi / etc/samba/smb.conf / / enter the configuration file

5.1 make the following global configuration changes in global:

Workgroup = WORKGROUP// defines a workgroup, that is, the concept of a workgroup in windows

Security = user / / Security authentication is based on user

Ntlm auth = yes / / otherwise windows7 access users will fail authentication

Add a new user profile to conf (let the configuration of 4 take effect)

[lcd]

Path = / cloud/lcd / / shared directory

Browsable = yes

Writable = yes / / directory is readable and writable

Read only = no

The modified smb.conf is as follows:

[global]

Workgroup = WORKGROUP

Security = user

Passdb backend = tdbsam

Printing = cups

Printcap name = cups

Load printers = yes

Cups options = raw

Ntlm auth = yes

[homes]

Comment = Home Directories

Valid users =% S,% D%w%S

Browseable = No

Read only = No

Inherit acls = Yes

[printers]

Comment = All Printers

Path = / var/tmp

Printable = Yes

Create mask = 0600

Browseable = No

[print$]

Comment = Printer Drivers

Path = / var/lib/samba/drivers

Write list = @ printadmin root

Force group = @ printadmin

Create mask = 0664

Directory mask = 0775

[lcd]

Path = / cloud/lcd

Browsable = yes

Writable = yes

Read only = no

Step 6: set the file permissions of the directory you want to share

Add write permissions to the shared directory so that you can write files from windows to linux. For example, if I set\ home as the shared directory here, enter the following command on the terminal.

Chmod-R 777 / cloud/lcd (writable wrap4, readable, Red2, executable, xtun1)

Step 7: restart the samba service

"systemctl restart smb

Testing and use:

Win7:\ 10.xx.xx.xx\ lcd prompts for the account password.

-

Copyright notice: this article is the original article of CSDN blogger "sparrowwf", in accordance with the CC 4.0BY-SA copyright Agreement. Please attach the original source link and this statement for reprint.

Original link: https://blog.csdn.net/sparrowwf/article/details/81064318

First mount the CentOS CD file

[root@localhost /] # yum install samba

[root@localhost /] useradd-s / sbin/nologin jitai1

[root@localhost /] smbpasswd-a jitai1

[root@localhost /] # vi / etc/samba/smb.conf

[root@localhost /] # cat / etc/samba/smb.conf

[global]

Workgroup = SAMBA workgroup = WORKGROUP security = user ntlm auth = yes passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw

[homes]

Comment = Home Directories

Valid users =% S,% D%w%S

Browseable = No

Read only = No

Inherit acls = Yes

[printers]

Comment = All Printers

Path = / var/tmp

Printable = Yes

Create mask = 0600

Browseable = No

[print$]

Comment = Printer Drivers

Path = / var/lib/samba/drivers

Write list = @ printadmin root

Force group = @ printadmin

Create mask = 0664

Directory mask = 0775

[jitai1]

Comment = jitai1

Path = / tmp/jitai1

Browsable = yes

Writable = yes

Read only = no

Win 10 allows the network drive to map the jitai1 directory.

Notepad for win10, enter as follows and save as startupZ.bat file

Net use Z:\ 10.24.11.93\ jitai1 jitai1 / user:jitai1 / persistent:yes

1. First of all, in the lower-left corner of the computer, click the start menu and select the "run" option in the menu.

two。 Then type "shell:startup" in the run window and click OK.

3. The folder window that opens at this time is the windows10 launch interface.

4. Put startupZ.bat into this directory, and boot automatically maps the network drive.

A server 10.24.11.93:

[root@cent7x64] # ssh-keygen-t rsa

[root@cent7x64] # cat ~ / .ssh/id_rsa.pub

[root@cent7x64 ~] # scp id_rsa.pub root@10.24.11.91:/root/.ssh/authorized_keys

Server B 10.24.11.91:

[root@cent7x64] # ssh-keygen-t rsa

[root@cent7x64] # cat ~ / .ssh/id_rsa.pub

[root@cent7x64 ~] # scp id_rsa.pub root@10.24.11.93:/root/.ssh/authorized_keys

Copy the file from 10.24.11.93 to 10.24.11.91:

[root@cent7x64 ~] cat bakjitai1.sh

#! / bin/bash

Scp-r / tmp/jitai1/ root@10.24.11.91:/tmp/jitai1date +% Y%m%ddate +% H:%M:%S

[root@localhost tmp] # cat rmrfjitai1.sh

! # / bin/bash

Rm-rf / tmp/jitai1/.

[root@localhost tmp] # cat / etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

For details see man 4 crontabsExample of job definition:.- minute (0-59) |.-hour (0-23) | |.-day of month (1-31) |.-month (1-12) OR jan,feb,mar,apr. |.-day of week (0-6) (Sunday=0 or 7) OR sun,mon Tue,wed,thu,fri,sat | | * user-name command to be executed

/ 2 * root / tmp/bakjitai1.sh

/ 3 * root / tmp/rmrfjitai1.sh

If you copy it regularly, you don't need password verification.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report