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

SMB file sharing-- experiment

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

Share

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

Experimental environment: RHEL7.0

Server server1.example.com 172.25.254.1

Client server2.example.com 172.25.254.2

1. Install and configure SMB

1.1 installation

[root@server1 ~] # yum install samba samba-client-y

[root@server1 ~] # systemctl start smb

[root@server1 ~] # systemctl enable smb

1.2 configure Fire Wall Policy

[root@server1] # firewall-cmd-- permanent-- add-service=samba

[root@server1] # firewall-cmd-- permanent-- add-service=samba-client

[root@server1] # firewall-cmd-- reload

1.3Adding smb users

[root@server1 ~] # useradd willis # # create a user

[root@server1 ~] # useradd student

[root@server1 ~] # smbpasswd-a willis # # newly created as smb user and encrypted

New SMB password:

Retype new SMB password:

Added user willis.

[root@server1] # smbpasswd-a student

New SMB password:

Retype new SMB password:

Added user student.

[root@server1] # pdbedit-L

Willis:1001:

Student:1002:

[root@server1] # smbclient-L / / 172.25.254.1-U student

Enter student's password:

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Sharename Type Comment

-

IPC$ IPC IPC Service (Samba Server Version 4.1.1)

Student Disk Home Directories

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Server Comment

--

Workgroup Master

--

[root@server1 ~] # smbclient / / 172.25.254.1/student-U student

Enter student's password:

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Smb:\ > ls

. D 0 Thu Sep 22 18:33:14 2016

.. D 0 Thu Sep 22 18:33:14 2016

.mozilla DH 0 Thu Aug 4 23:45:35 2016

.bash _ logout H 18 Wed Jan 29 20:45:18 2014

.bash _ profile H 193 Wed Jan 29 20:45:18 2014

.bashrc H 231 Wed Jan 29 20:45:18 2014

34808 blocks of size 262144. 22711 blocks available

Smb:\ > quit

two。 Change to a shared directory

2.1 self-built catalogue

[root@server1 ~] # mkdir / share

[root@server1 ~] # vim / etc/samba/smb.conf

[test]

Comment = test share

Path = / share

[root@server1 ~] # touch / share/file

[root@server1 ~] # smbclient / / 172.25.254.1/test-U willis

Enter willis's password:

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Smb:\ > ls

. D 0 Thu Sep 22 20:15:26 2016

.. D 0 Thu Sep 22 18:41:38 2016

File N 0 Thu Sep 22 20:15:26 2016

34808 blocks of size 262144. 22696 blocks available

Smb:\ >

2.2 shared system directory

[root@server1 ~] # vim / etc/samba/smb.conf

[test]

Comment = test share

Path = / mnt

[root@server1 ~] # ls / mnt/

[root@server1 ~] # touch / mnt/file1

[root@server1 ~] # smbclient / / 172.25.254.1/test-U willis

Enter willis's password:

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Smb:\ > ls

. D 0 Thu Sep 22 20:18:31 2016

.. D 0 Thu Sep 22 18:41:38 2016

File1 N 0 Thu Sep 22 20:18:31 2016

34808 blocks of size 262144. 22696 blocks available

Smb:\ >

3. Reform the working group

[root@server1] # smbclient-L / / 172.25.254.1-U willis

Enter willis's password:

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Sharename Type Comment

-

Test Disk test share

IPC$ IPC IPC Service (Samba Server Version 4.1.1)

Willis Disk Home Directories

Domain= [MYGROUP] OS= [Unix] Server= [Samba 4.1.1]

Server Comment

--

Workgroup Master

--

[root@server1 ~] #

[root@server1 ~] # vim / etc/samba/smb.conf

Workgroup = willis

[root@server1] # smbclient-L / / 172.25.254.1-U willis

Enter willis's password:

Domain= [WILLIS] OS= [Unix] Server= [Samba 4.1.1]

Sharename Type Comment

-

Test Disk test share

IPC$ IPC IPC Service (Samba Server Version 4.1.1)

Willis Disk Home Directories

Domain= [WILLIS] OS= [Unix] Server= [Samba 4.1.1]

Server Comment

--

Workgroup Master

--

[root@server1 ~] #

4. Host settings that allow / deny access to the service

[root@server1 ~] # vim / etc/samba/smb.conf (effective immediately with the change)

Hosts deny = 172.25.254.2

Test:

[root@server2] # smbclient-L / / 172.25.254.1-U willis

Enter willis's password:

Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE

5. Client mount use

RHEL6 can be logged in and mounted anonymously (share level)

RHEL 7 cannot be mounted anonymously

Server side:

[root@server1 ~] # vim / etc/samba/smb.conf

Security = user

Passdb backend = tdbsam

Map to guest = bad user # add this sentence

[test]

Comment = test share

Path = / share

Guest ok = yes # add this sentence

[root@server1 ~] # systemctl restart smb.service

Client:

[root@server2 mnt] # mount / / 172.25.254.1/test / mnt-o username=willis,password=redhat

[root@server2 mnt] # df-h

/ / 172.25.254.1/test 8.5G 3.0G 5.6G 35% / mnt

Common parameters

[test]

Guest ok = yes # Anonymous users can log in

Browseable = no # hide the share

Writable = yes # allows all users to write

Weite list = student # only student is allowed to write

Write list = + student

Write list = @ student # allows student user groups to write + as well as @

Valid users = + student # test this group can only be used by student user groups

Admin users = student # student is running as root

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