安装 Samba 服务
[root@samba ~]# hostnamectl set-hostname samba
[root@samba ~]# yum install -y samba
配置 samba 的配置文件 /etc/samba/smb.conf
[root@samba ~]# vi /etc/samba/smb.conf
[share]
comment = samba share
path = /opt/share #共享目录
browseable = yes #操作权限
public = yes #访问权限
writable =yes #对文件的操作权限
创建目录并赋予权限
[root@samba ~]# mkdir /opt/share
[root@samba ~]# chmod 777 /opt/share
启动 samba 服务
[root@samba ~]# systemctl start smb
[root@samba ~]# systemctl start nmb
查看端口启动情况 (必须安装了 net-tools 软件包)
[root@samba ~]# yum install -y net-tools
[root@samba ~]# netstat -ntpl
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:139 0.0.0.0:* LISTEN 4460/smbd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1114/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1360/master
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 4460/smbd
tcp6 0 0 :::139 :::* LISTEN 4460/smbd
tcp6 0 0 :::22 :::* LISTEN 1114/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1360/master
tcp6 0 0 :::445 :::* LISTEN 4460/smbd
创建 Samba 用户 —— root用户并设置密码
[root@samba ~]# smbpasswd -a root #用户必须存在
New SMB password:
Retype new SMB password:
Added user root.
创建 Samba 用户 ——— 普通用户并设置密码
[root@samba ~]# smbpasswd -a AH
New SMB password:
Retype new SMB password:
Added user AH.
重启 Samba 服务
[root@samba ~]# service smb restart
Redirecting to /bin/systemctl restart smb.service
拓展
现在登录用户为AH现在换成root有两种方法
方法一 用命令
再次登录就行
匿名登录
[root@samba ~]# vi /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
map to guest =bad user #允许匿名登陆
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
匿名登陆会直接进入无法选择登录用户