基本环境:
centos: 7.2 版本
安装步骤:
1. centos 安装 samba
1
|
yum install samba samba - client samba - swat |
2. 启动samba
1
|
service smb start |
3. 查看 samba 状态
1
|
service smb status |
4. 开机自动启动samba (3,5级别的开机自动启动samba)
1
|
chkconfig - - level 35 smb on |
5. 配置 conf 文件(*******)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
1. 备份数据 备份:cp / etc / samba / smb.conf / etc / samba / smb.confbak 恢复:cp / etc / samba / smb.confbak / etc / samba / smb.conf vi / etc / samba / smb.conf 2. 配置相关参数 [ global ] #找到这一行(全局设置标签),在此行下面添加如下行: workgroup = WORKGROUP #工作组名称改为 Windows 网络所定义的工作组名 server string = Samba Server #设置samba服务器的主机名称 security = user #设置samba服务器安全级别为user,即以账号和口令访问 #在配置文件的末尾添加以下自定义内容 [SambaServer] comment = SambaServer #在Windows网上邻居中看到的共享目录的名字 path = / home / SambaServer #共享目录在系统中的位置 public = no #不公开目录 writable = yes #共享目录可以读写 valid users = SambaServer #只允许SambaServer用户访问 保存配置 3 、添加访问linux共享目录的账号SambaServer(建议samba 用户单独设置一个用户名,使之不能登录系统) 用户家目录为 / home / SambaServer, 用户登录终端设为 / bin / false(即使之不能登录系统) cd / home #进入/home目录 mkdir SambaServer #建立SambaServer文件夹 touch samba.txt #创建测试文件samba.txt useradd SambaServer - d / home / SambaServer - s / bin / false chown SambaServer:SambaServer / home / SambaServer - R 4 、将用户SambaServer添加入到Samba用户数据库,并设置登录共享目录的密码为: 123456 smbpasswd - a SambaServer New SMB password: 输入该用户用于登录Samba的密码 Retype new SMB password: 再次确认输入该密码 Added user SambaServer. #特别注意:这里设置的密码是用户登录Samba共享目录的密码,不是用户登录linux系统的密码 5 、重启Samba服务器 service smb restart 6 、在Windows客户端输入 \\ip或者\\Samba Server #服务器名称 回车之后,会跳出来登录框,输入账号SambaServer 密码 123456 即可访问共享目录 |
6. 到终端远程登录。


问题汇总:
1. samba 无法启动
1
2
3
4
|
smb.service - Samba SMB Daemon Loaded: loaded ( / usr / lib / systemd / system / smb.service; enabled; vendor preset: disabled) Active: failed (Result: exit - code) since 三 2018 - 03 - 28 23 : 38 : 31 CST; 5s ago Process: 4746 ExecStart = / usr / sbin / smbd $SMBDOPTIONS (code = exited, status = 1 / FAILURE) |
主要是配置错误导致的,将配置改为最原始的配置,然后试试能不能启动。
2. 启动后无法连接
腾讯云需要在安全组开启 139,445 端口,并关联对应服务器。