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

Samba

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

# samba#

1samba action

Provide cifs protocol to realize file sharing

2 installation

Yum install samba samba-common samba-client-y

Systemctl start smb nmb

Systemctl enable smb nmb

Systemctl stop firewalld.service

3 add smb user

Smb users must be local users

Smbpasswd-a student

New SMB password: # enter the smb current user password

Retype new SMB password:# confirm password

Added user student.

Pdbedit-L # View smb user information

Student:1000:Student User

Pdbedit-x student# delete smb user

Setsebool-P samba_enable_home_dirs on # # set smb users to access their home directories in selinux

4 basic settings of shared directory

one hundred and seventeen

Mkdir / smbshare

Touch / smbshare/123

Vim / etc/samba/smb.conf

321 [westos] # # share name

322 comment = local directory # # description of shared directories

323 path = / smbshare # # absolute path to the shared directory

When the shared directory is a user-built directory

Semanage fcontext-a-t samba_share_t'/ smbshare (/. *)?'

Restorecon-Rvvf / smbshare/

Systemctl restart smb.service

test

seventeen

[root@dns-server Desktop] # smbclient / / 172.25.254.117/westos-U student

Enter student's password:

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

Smb:\ > ls

. D 0 Sat Jun 3 14:39:20 2017

.. D 0 Sat Jun 3 14:39:12 2017

123 N 0 Sat Jun 3 14:39:20 2017

10473900 blocks of size 1024. 7316272 blocks available

Smb:\ > SMBecho failed (NT_STATUS_CONNECTION_DISCONNECTED). The connection is disconnected now

When a shared directory establishes a directory for the system

Setsebool-P samba_export_all_ro on# read-only sharing

Setsebool-P samba_export_all_rw on# read and write sharing

Systemctl restart smb.service

test

seventeen

[root@dns-server Desktop] # smbclient / / 172.25.254.117/westos-U student

Enter student's password:

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

Smb:\ > ls

. D 0 Sat Jun 3 13:54:54 2017

.. D 0 Sat Jun 3 14:39:12 2017

Fstab N 313 Wed May 7 09:22:57 2014

Crypttab N 0 Wed May 7 09:22:57 2014

Mtab R 0 Sat Jun 3 14:47:19 2017

Pki D 0 Wed May 7 09:27:13 2014

Rpm D 0 Fri Jul 11 06:36:36 2014

Yum D 0 Wed May 7 09:24:49 2014

Issue N 23 Tue Apr 1 21:28:10 2014

Binfmt.d D 0 Wed Apr 2 21:30:23 2014

Issue.net N 22 Tue Apr 1 21:28:10 2014

Modules-load.d D 0 Wed Apr 2 21:30:23 2014

Os-release N 493 Tue Apr 1 21:28:10 2014

Fonts D 0 Fri Jul 11 06:22:37 2014

Redhat-release N 52 Tue Apr 1 21:28:10 2014

DIR_COLORS.256color N 5725 Sat Jan 25 03:23:50 2014

.

Configuration parameters of 5samba

# Anonymous user access

Vim / etc/samba/smb.conf

125 map to guest = bad user

324guest ok = yes

test

seventeen

[root@dns-server Desktop] # smbclient / / 172.25.254.117/westos

Enter kiosk's password: # No password

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

Smb:\ > ls

. D 0 Sat Jun 3 14:39:20 2017

.. D 0 Sat Jun 3 14:39:12 2017

123 N 0 Sat Jun 3 14:39:20 2017

10473900 blocks of size 1024. 7305320 blocks available

# access Control

Hosts allow = # # only allowed

Hosts deny = # # reject only

Valid users = # valid users currently shared

Valid users = westos# the valid user for the current share is westos

Valid users = @ westos# the valid user of the current share is westos group

Valid users = + westos# the valid user currently shared is the westos group

test

one hundred and seventeen

Vim / etc/samba/smb.conf

325 hosts allow = 172.25.254.17

seventeen

[root@dns-server Desktop] # smbclient / / 172.25.254.117/westos

Enter kiosk's password:

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

Smb:\ > ls

. D 0 Sat Jun 3 14:39:20 2017

.. D 0 Sat Jun 3 14:39:12 2017

123 N 0 Sat Jun 3 14:39:20 2017

10473900 blocks of size 1024. 7305276 blocks available

two hundred and seventeen

[root@localhost ~] # smbclient / / 172.25.254.117/westos

Enter root's password:

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

Tree connect failed: NT_STATUS_ACCESS_DENIED

test

one hundred and seventeen

Vim / etc/samba/smb.conf

324 valid users = westos

seventeen

[root@dns-server Desktop] # useradd westos-s / sbin/nologin

[root@dns-server Desktop] # smbpasswd-a westos

New SMB password:

Retype new SMB password:

Added user westos.

[root@dns-server Desktop] # smbclient / / 172.25.254.117/westos-U westos

Enter westos's password:

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

Smb:\ >

# # read and write Control

All users can write

Chmod odeciw / smbshare # # modify shared directory permissions

Setsebool-P samba_export_all_rw on

Vim / etc/samba/smb.conf

324 writable = yes

Systemctl restart smb.service

test

seventeen

[root@dns-server Desktop] # mount-o username=westos,password=redhat / / 172.25.254.117/westos / mnt/

[root@dns-server Desktop] # cd / mnt/

[root@dns-server mnt] # ls

one hundred and twenty three

[root@dns-server mnt] # touch file3

[root@dns-server mnt] # ls

123 file3

Set the specified user writable

Write list = student # writable user

Write list = + student# writable user group

Write list = @ stident

Admin users = superuser assignment of the westos# share

test

one hundred and seventeen

Vim / etc/samba/smb.conf

324 writable = no

325 write list = student

two hundred and seventeen

Smbpasswd-a student

Useradd westos

Usermod-G westos student

Mount-o username=student,password=123 / / 172.25.254.117/westos / mnt/

[root@localhost mnt] # ls

123 1234fref file3

[root@localhost mnt] # touch file5

[root@localhost mnt] # ls

123 1234fref file3 file5

test

one hundred and seventeen

Vim / etc/samba/smb.conf

324 writable = yes

325 admin users = westos

two hundred and seventeen

[root@localhost] # mount-o username=westos,password=redhat / / 172.25.254.117/westos / mnt/

[root@localhost ~] # cd / mnt/

[root@localhost mnt] # ls

123 1234fref file3 file5

[root@localhost mnt] # touch file6

[root@localhost mnt] # ls-l file6

-rw-r--r--. 1 root westos 0 June 3 04:36 file6

6smb multi-user mount

On client (client)

Vim / root/

Username=student

Password=123 # # password is smb password

Chmod 600 / root/

Yum install cifs-utils.x86_64-y

Mount-o credentials=/root/,multiuser,sec=ntlmssp / / 172.25.254.117/westos / mnt/

# credentials=/root/ specifies the user files used for mounting

# multiuser supports multi-user authentication

# sec=ntlmssp authentication is standard smb authentication

[root@localhost ~] # su-westos

[westos@localhost ~] $ls / mnt

Ls: cannot access / mnt: Permission denied # cannot access the share of smb because it is not authenticated by smb

[westos@localhost] $cifscreds add-u westos 172.25.254.117

Password: # # password of smb user westos

[westos@localhost ~] $ls / mnt

123 1234fref file3 file5 file6

[westos@localhost ~] $

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