共享一个文件夹,可以在windows去设置文件共享,在Linux中我们也可以设置文件共享功能;
#1.下载服务
apt-get update
apt-get install samba
// 查看所有的服务及相关信息
systemctl list-unit-files
systemctl list-unit-files | grep ssh
#2.启动服务
systemctl status samba-ad-dc.service
systemctl status smbd.service
systemctl start smbd.service
\\192.168.116.128 在windows的文件夹管理系统上
此时反馈拒绝服务
┌──(rootkali)-[/]
└─# cd /etc/samba
┌──(rootkali)-[/etc/samba]
└─# ls
gdbcommands smb.conf tls
┌──(rootkali)-[/etc/samba]
└─# vim smb.conf
#3.编辑配置文件
vim /etc/samba/smb.conf
[Share]
path = /etc
public = yes #把yes改成no 再次访问,就需要输入用户名和密码
writable = yes
available = yes
browseable = yes
hosts deny = 192.168.113.
hosts allow = 192.168.1.3
C:\Users\user>net use * /delete #在cmd中(物理机)清空链接的缓存
systemctl restart smbd.service #4.重启服务
[global] //设置samba服务整体环境
workgroup = WORKGROUP //设置工作组名称
server string = Samba Server Version %v //服务器说明
[laiGei] //共享目录的名称
comment = Public stuff //注释说明
path = /usr/local/laige //共享目录的路径
public = yes //是yes/否no公开共享,若为否则进行身份验证(只有当security = share 时此项才起作用)
writeable = yes //是yes/否no不以只读方式共享当与read only发生冲突时,无视read only
browseable = yes //是yes/否no在浏览资源中显示共享目录,若为否则必须指定共享路径才能存取
guest ok = yes //是yes/否no公开共享,若为否则进行身份验证(只有当security = share 时此项才起作用)
useradd apple #5.新建一个用户
smbpasswd -a apple #6.通过smbpasswd 修改smb服务的密码
smbpasswd -a 增加用户
smbpasswd -d 冻结用户,这个用户不可登录
smbpasswd -e 恢复用户,解冻用户
smbpasswd -x 删除用户
Windows环境使用:
\\192.168.6.210\samba
输入设置的samba用户名和密码
Linux环境使用:
mount //192.168.6.210/samba /media -o username=apple,password=apple123
┌──(rootkali)-[/]
└─# chmod 777 /123
┌──(rootkali)-[/etc/samba]
└─# useradd 123
┌──(rootkali)-[/etc/samba]
└─# smbpasswd -a 123
New SMB password:
Retype new SMB password:
Added user 123.sudo passwd root
apt-get update
apt-get install samba #1.下载服务
yum install samba -y
systemctl status smbd.service
systemctl start smbd.service #2.启动服务
\\192.168.116.128 在windows的文件夹管理系统上
┌──(rootkali)-[/]
└─# cd /etc/samba
┌──(rootkali)-[/etc/samba]
└─# ls
gdb commands smb.conf tls
┌──(rootkali)-[/etc/samba]
└─# vim smb.conf
vim /etc/samba/smb.conf #3.编辑配置文件
[Share]
path = /etc #设置默认路径
public = yes #yes不需要密码
writable = yes
available = yes
browseable = yes
#改完之后,重启服务
┌──(rootkali)-[/etc/samba]
└─# systemctl restart smbd.service
systemctl restart smbd.service
┌──(rootkali)-[/etc/ssh]
└─# useradd samba
┌──(rootkali)-[/etc/ssh]
└─# smbpasswd -a samba
hosts deny = 192.168.
#deny是阻止连接
hosts allow = 192.168.43.246
#allow是允许连接