当前位置: > Ubuntu >

Ubuntu下配置samba实现文件夹共享

时间:2016-12-16 17:23来源:linux.it.net.cn 作者:IT

安装samba软件包


					
1
2

					
ansheg@ansheng-me:~$ sudo apt-get install samba
ansheg@ansheng-me:~$ sudo apt-get install smbfs

创建samba共享目录


					
1
2
3
4

					
ansheg@ansheng-me:~$ pwd
/home/ansheg
ansheg@ansheng-me:~$ mkdir share
ansheg@ansheng-me:~$ sudo chmod 777 share/

创建Samba配置文件

备份现有的配置文件


					
1

					
ansheg@ansheng-me:~$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

修改现配置文件

在smb.conf最后添加以下内容


					
1
2
3
4
5
6
7

					
ansheg@ansheng-me:~$ sudo tail -6 /etc/samba/smb.conf
[share]
path = /home/ansheg/share
available = yes
browsealbe = yes
public = yes
writable = yes

创建samba帐户


					
1
2
3
4
5

					
ansheg@ansheng-me:~$ sudo touch /etc/samba/smbpasswd
ansheg@ansheng-me:~$ sudo smbpasswd -a ansheng
New SMB password:
Retype new SMB password:
Failed to add entry for user ansheng.

然后会要求你输入samba帐户的密码

如果没有第四步,当你登录时会提示 session setup failed: NT_STATUS_LOGON_FAILURE

重启samba服务器


					
1

					
ansheg@ansheng-me:~$ sudo systemctl restart smbd

测试

安装smbclient程序


					
1

					
ansheg@ansheng-me:~$ sudo apt install smbclient

					
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

					
ansheg@ansheng-me:~$ smbclient -L //localhost/share
WARNING: The "syslog" option is deprecated
Enter ansheg's password:
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.8-Ubuntu]
 
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
share Disk
IPC$ IPC IPC Service (ansheng-me server (Samba, Ubuntu))
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.8-Ubuntu]
 
Server Comment
--------- -------
ANSHENG-ME ansheng-me server (Samba, Ubuntu)
V
 
Workgroup Master
--------- -------
WORKGROUP V

使用

可以到windows按Win+r,然后输入对于的地址就可以使用了,”\“+”IP”+”\”+”share”。




(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容