一、Samba 安装
user03g@local:~$ sudo apt update
user03g@local:~$ sudo apt install samba
二、Samba配置
1、修改 samba 配置文件
user03g@local:~$ sudo vim /etc/samba/smb.conf
2、在 /etc/samba/smb.conf 文件后面新增内容
[Home]
comment = Home Share
path = /home/user03
public = yes
browseable = yes
read only = no
valid users = user03
create mask = 0777
directory mask = 0777
force user = user03
force group = user03
available = yes
3、重启 samba 服务
user03@local:~$ sudo systemctl restart smbd
4、设置 samba 用户名和密码
user03@local:~$ sudo smbpasswd -a user03
New SMB password:
Retype new SMB password:
Added user deng.
三、实现Windows主机访问Samba服务器:
1、 在“运行”中输入Samba服务器的IP地址,并回车
![](https://i-blog.csdnimg.cn/blog_migrate/73a11a896c5a3fb499232efb8db30cd1.png)
2、 在弹出的登录界面中输入Samba的账户st02及密码:
![](https://i-blog.csdnimg.cn/blog_migrate/42b32ca914b04d734044fc84092f9fbb.jpeg)
3、 访问Samba服务器成功:
![](https://i-blog.csdnimg.cn/blog_migrate/39ddd64ca76d41d79c686df2d812e543.jpeg)
四、Linux主机访问Windows共享文件
1、 在Windows主机中创建共享目录
![](https://i-blog.csdnimg.cn/blog_migrate/740ab3d7a24f83fa7f13b3354586867d.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/8cdcf4c13e18044cb3dc76b1b6794954.jpeg)
2、 使用sbmclient命令来连接Windows共享目录
使用来宾账号Guest(密码为空)来登录访问Windows的共享资源
# smbclient //192.168.1.254/share -U Guest
Password:
Domain=[XULAU] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: /> dir
. D 0 Wed Jun 10 05:46:45 2009
.. D 0 Wed Jun 10 05:46:45 2009
360safefixavi.exe A 402952 Sun May 31 07:49:21 2009
avseq03.wmv A 8062020 Sat Jun 6 03:11:22 2009
EasyInstallMakerV2.2_XiaoSD.exe A 1341058 Sat May 30 08:46:03 2009
FireFox 3.0.8.exe A 7339968 Mon Apr 20 07:18:42 2009
kav8.0.0.506sch.exe A 38302992 Thu Dec 4 20:22:00 2008
mysql-5.1.35.tar.gz A 35152597 Fri Jun 5 23:51:45 2009
53615 blocks of size 1048576. 5523 blocks available
smb: /> exit
3、 使用mount命令挂载Windows共享目录
# mkdir /winshare
# ll /winshare
total 0
# mount -t smbfs -o username=Guest //192.168.1.254/share /winshare
Password:
# ll /winshare
total 88480
-rwxr-xr-x 1 root root 402952 May 31 07:49 360safefixavi.exe
-rwxr-xr-x 1 root root 8062020 Jun 6 03:11 avseq03.wmv
-rwxr-xr-x 1 root root 1341058 May 30 08:46 EasyInstallMakerV2.2_XiaoSD.exe
-rwxr-xr-x 1 root root 7339968 Apr 20 07:18 FireFox 3.0.8.exe
-rwxr-xr-x 1 root root 38302992 Dec 4 2008 kav8.0.0.506sch.exe
例子:
[homes]
comment = Home Directories
browseable =
no
writable =
yes
[public_share]
comment = This is my share
path = /home/public_share
browseable =
yes
writable =
yes
public =
yes
guest
ok =
yes
[Company_File]
comment = This is company share
path = /home/CompanyFile
browseable =
yes
writeable =
yes
public =
yes
guest
ok =
yes挂载成功!