Linux_搭建Samba服务(匿名访问)
【RHEL8】—SMBserver;【RHEL7】—SMBclient
!!!测试环境我们首关闭防火墙和selinux(SMBserver和SMBclient都需要)
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@localhost ~]# setenforce 0
关于Samba配置文件的说明,访问:https://www.cnblogs.com/520qiangge/p/13413414.html
一、Samba服务端配置
1、首先查看服务端IP
[root@SMBserver ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.174.128 netmask 255.255.255.0 broadcast 192.168.174.255
inet6 fe80::fa13:32e0:3b9f:2196 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:cd:6a:1b txqueuelen 1000 (Ethernet)
RX packets 2779 bytes 211310 (206.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1090 bytes 110886 (108.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 60 bytes 5208 (5.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 60 bytes 5208 (5.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2、SMBserver安装Samba服务,并设置开机自启
[root@SMBserver ~]# yum install -y samba
[root@SMBserver ~]# rpm -qa samba
samba-4.10.4-1.el8.x86_64
[root@SMBserver ~]# systemctl start smb
[root@SMBserver ~]# systemctl start nmb
[root@SMBserver ~]# systemctl enable smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.
[root@SMBserver ~]# systemctl enable nmb
Created symlink /etc/systemd/system/multi-user.target.wants/nmb.service → /usr/lib/systemd/system/nmb.service.
3、查看端口是否监听
[root@SMBserver ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1083/sshd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 24412/smbd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 24412/smbd
tcp6 0 0 :::22 :::* LISTEN 1083/sshd
tcp6 0 0 :::445 :::* LISTEN 24412/smbd
tcp6 0 0 :::139 :::* LISTEN 24412/smbd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1588/dhclient
udp 0 0 192.168.174.255:137 0.0.0.0:* 24420/nmbd
udp 0 0 192.168.174.128:137 0.0.0.0:* 24420/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 24420/nmbd
udp 0 0 192.168.174.255:138 0.0.0.0:* 24420/nmbd
udp 0 0 192.168.174.128:138 0.0.0.0:* 24420/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 24420/nmbd
4、创建共享资源目录,并给予完全共享的(给全部的权限)
[root@SMBserver ~]# mkdir -p /sambadir/share
[root@SMBserver ~]# chmod 777 /sambadir/share/
[root@SMBserver ~]# ll /sambadir/
总用量 0
drwxrwxrwx. 2 root root 6 8月 1 10:33 share
5、编辑配置文件
[root@SMBserver ~]# vim /etc/samba/smb.conf
[root@SMBserver ~]# cat /etc/samba/smb.conf
[global]
workgroup = WORKGROUP //这里换成WODGROUP
security = user //这里不换成share,就用user,后面照样不用输入密码
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
map to guest = bad user //匿名用户最主要就是添加这行,可以实现匿名访问 [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 [share] //自己创建的共享文件名,也可以不一样
comment = my first samba-file //访问提示信息
path = /sambadir/share //文件路径
browseable = yes //是否可以浏览(是否浏览权限(yes为可见共享,no为隐藏共享))
public = yes //是否公开(指明该共享资源是否能给游客帐号访问)
writable = yes //是否可以写入文件(是否有写权限)
6、测试smb.conf文件语法是否错误
[root@SMBserver ~]# testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions
//这里提示这样的信息,叫你回车就会显示刚刚写的配置文件的内容,就代表没有语法错误,我就没回车了,节省时间
7、重启smb,nmb服务
[root@SMBserver ~]# systemctl restart smb
[root@SMBserver ~]# systemctl restart nmb
[root@SMBserver ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1083/sshd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 24631/smbd
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 24631/smbd
tcp6 0 0 :::22 :::* LISTEN 1083/sshd
tcp6 0 0 :::445 :::* LISTEN 24631/smbd
tcp6 0 0 :::139 :::* LISTEN 24631/smbd
udp 0 0 0.0.0.0:68 0.0.0.0:* 1588/dhclient
udp 0 0 192.168.174.255:137 0.0.0.0:* 24642/nmbd
udp 0 0 192.168.174.128:137 0.0.0.0:* 24642/nmbd
udp 0 0 0.0.0.0:137 0.0.0.0:* 24642/nmbd
udp 0 0 192.168.174.255:138 0.0.0.0:* 24642/nmbd
udp 0 0 192.168.174.128:138 0.0.0.0:* 24642/nmbd
udp 0 0 0.0.0.0:138 0.0.0.0:* 24642/nmbd
到这里匿名访问的服务端就配置完成
二、Samba客户端配置
1、SMBclient查看是否有安装samba-client,cifs-utils软件包
[root@smbclient ~]# yum info samba-client cifs-utils
已加载插件:product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
可安装的软件包
名称 :cifs-utils
架构 :x86_64
版本 :6.2
发布 :10.el7
大小 :85 k
源 :dvd
简介 : Utilities for mounting and managing CIFS mounts
网址 :http://linux-cifs.samba.org/cifs-utils/
协议 : GPLv3
描述 : The SMB/CIFS protocol is a standard file sharing protocol widely deployed
: on Microsoft Windows machines. This package contains tools for mounting
: shares on Linux using the SMB/CIFS protocol. The tools in this package
: work in conjunction with support in the kernel to allow one to mount a
: SMB/CIFS share onto a client and use it as if it were a standard Linux
: file system. 名称 :samba-client
架构 :x86_64
版本 :4.6.2
发布 :8.el7
大小 :597 k
源 :dvd
简介 : Samba client programs
网址 :http://www.samba.org/
协议 : GPLv3+ and LGPLv3+
描述 : The samba-client package provides some SMB/CIFS clients to complement
: the built-in SMB/CIFS filesystem in Linux. These clients allow access
: of SMB/CIFS shares and printing to SMB/CIFS printers.
2、安装samba-client,cifs-utils软件包
[root@smbclient ~]# yum install -y samba-client cifs-utils
[root@smbclient ~]# rpm -qa samba-client cifs-utils
cifs-utils-6.2-10.el7.x86_64
samba-client-4.6.2-8.el7.x86_64
3、客户端查看samba服务器有哪些共享资源
[root@smbclient ~]# smbclient -L 192.168.174.128
Enter SAMBA\root's password: //直接回车,不用输任何东西
OS=[Windows 6.1] Server=[Samba 4.10.4] Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
share Disk my first samba-file
IPC$ IPC IPC Service (Samba 4.10.4)
OS=[Windows 6.1] Server=[Samba 4.10.4] Server Comment
--------- ------- Workgroup Master
--------- -------
WORKGROUP SMBSERVER
4、客户端创建挂载目录
[root@smbclient ~]# mkdir /smbdir
5、客户端挂载服务端共享的资源
[root@smbclient ~]# mount.cifs -rw //192.168.174.128/share /smbdir/
Password for root@//192.168.174.128/share: //这里也是直接回车就行,不用输任何东西
[root@smbclient ~]#
6、查看是否挂载成功
[root@smbclient ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rhel-root 50G 1.1G 49G 3% /
devtmpfs 901M 0 901M 0% /dev
tmpfs 912M 0 912M 0% /dev/shm
tmpfs 912M 8.7M 904M 1% /run
tmpfs 912M 0 912M 0% /sys/fs/cgroup
/dev/sr0 3.8G 3.8G 0 100% /mnt
/dev/mapper/rhel-home 27G 33M 27G 1% /home
/dev/sda1 1014M 143M 872M 15% /boot
tmpfs 183M 0 183M 0% /run/user/0
//192.168.174.128/share 50G 2.0G 49G 4% /smbdir
//最后一行说明挂载成功
三、测试
1、首先在客户端创建两个文件,然后在服务端查看
//SMBclient
[root@smbclient ~]# cd /smbdir/
[root@smbclient smbdir]# ls
[root@smbclient smbdir]# touch {file1,file2}
[root@smbclient smbdir]# ls
file1 file2
[root@smbclient smbdir]# //SMBserver
[root@SMBserver ~]# cd /sambadir/share/
[root@SMBserver share]# ls
file1 file2
[root@SMBserver share]#
2、在windows的资源管理器上访问
Linux_搭建Samba服务(匿名访问)的更多相关文章
- Linux_搭建Samba服务(认证访问)
[RHEL8]-SMBserver:[RHEL7]-SMBclient !!!测试环境我们首关闭防火墙和selinux(SMBserver和SMBclient都需要) [root@localhost ...
- 如何在RHEL7上搭建Samba服务实现Windows与Linux之间的文件共享
如何在RHEL7上搭建Samba服务实现Windows与Linux之间的文件共享 实现环境:VMware workstations.RHEL7.0 第一步:配置网卡IP及yum软件仓库 命令:vim ...
- 搭建SAMBA服务
说明:这里是Linux服务综合搭建文章的一部分,本文可以作为单独搭建SABMA服务的参考. 注意:这里所有的标题都是根据主要的文章(Linux基础服务搭建综合)的顺序来做的. 如果需要查看相关软件版本 ...
- Centos6搭建Samba服务并使用Windows挂载
一.安装相关软件 [root@mail ~]# yum install samba samba-client -y #安装相关软件 二.配置匿名访问 [root@mail ~]# cd /etc/sa ...
- ubuntu系统搭建samba服务
安装samba服务 # apt-get install samba 创建一个samba服务的分享目录 # mkdir /share 创建一个samba服务限制的用户及组 #useradd public ...
- 如何搭建samba服务?
为了日后便于查询,本文所涉及到的所有命令集合如下: chkconfig iptables off #关闭防火墙命令 在Centos7中使用的是chkconfig firewalld off seten ...
- 笔记 : win8系统中的VM虚拟机的Ubuntu搭建samba服务
1. 环境准备 (此处使用root超级管理员帐户,执行命令时不用加sudo, 普通帐户需要前面加sudo): (1)安装好Ubutun虚拟系统后,Ubuntu 的软件源配置文件是 /etc/apt/ ...
- CentOS6.5下搭建Samba服务实现与Windows系统之间共享文件资源
FTP文件传输服务确实可以让主机之间的文件传输变得简单方便,但是FTP协议的本质是传输文件,而非共享文件,因此要想通过客户端直接在服务器上修改文件内容还是一件比较麻烦的事情. 1987年,微软公司和英 ...
- 演示vsftpd服务匿名访问模式、本地用户模式的配置
文件传输协议(FTP,File Transfer Protocol) 即能够让用户在互联网中上传.下载文件的文件协议,而FTP服务器就是支持FTP传输协议的主机,要想完成文件传输则需要FTP服务端和F ...
随机推荐
- c++ 实现向量去重操作
去重的时候要考虑线性表或链表是否是有序 1.1.无序线性表 对于向量[1,5,3,7,2,4,7,3], 从头开始扫描vector内的元素, 对于表中r处的元素a[r], 检查数组0至r-1区间内是否 ...
- ES系列(二):基于多播的集群发现实现原理解析
ES作用超强悍的搜索引擎,除了需要具有齐全的功能支持,超高的性能,还必须要有任意扩展的能力.一定程度上,它是一个大数据产品.而要做扩展性,集群自然少不了.然而单独的集群又是不够的,能够做的事情太少,所 ...
- Fiddler使用 断点 模拟返回 AutoResponder Mock 模拟数据 相关学习记录
断点 测试中有时需要改变发出去的请求信息,需要用到打断点的方法.断点包含两种方式: before response:在request请求的时候,未到达服务器之前,一般用来修改请求参数 after re ...
- java连接数据库(jdbc)的标准规范
java连接数据库的标准规范 JDBC全称:java database connectivity ,是sun公司提供的Java连接数据库的标准规范. localhost和127.0.0.1 都是表示当 ...
- CSS 还能这样玩?奇思妙想渐变的艺术
在之前的这篇文章 -- 一行 CSS 代码的魅力 中,我们介绍了一种使用一行 CSS 代码就能够生成的一种美妙(也许奇怪更合适)的背景. 本文,将继续介绍背景的一些有意思的知识,利用一些极小的单位,只 ...
- 解决mysql You can't specify target table for update in FROM clause错误
mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表( ...
- G - G ZOJ - 2723 (素数打表+set)
Prime Number Definition An integer greater than one is called a prime number if its only positive di ...
- linux删除文件空间不释放问题解决
目录 场景描述 原因 解决方法 在线清空文件 场景描述 某天,收到Prometheus报警,生产中某台机器出现磁盘空间不足报警,该台服务器是mysql其中一台从库,远程登录到该服务后,排查磁盘空间的原 ...
- 【Springboot】Springboot监听器Demo
/** * @author: yq * @date: 2020/8/31 0:01 * @description 自定义事件 */ @Data public class MyEvent extends ...
- 【多线程】Java线程池七个参数详解
/** * Creates a new {@code ThreadPoolExecutor} with the given initial * parameters. * * @param coreP ...