Linux samba配置与使用(fedora 22)

来源:互联网 发布:php java 前景 编辑:程序博客网 时间:2024/05/24 03:25

Fedora 22环境下:

配置samba

smbpasswd -a -U your_username               #设置登陆的用户名和密码,你可以运行 whoami 查看你的用户名
systemctl enable smb.service                           # 开机启动samba
systemctl start smb.service                               #  立即启动samba
systemctl restart smb.service                             # 立即重启samba
firewall-cmd --permanent --zone=public --add-service=samba                           # 配置防火墙,让其它电脑能访问你的电脑。

增加
共享文件夹

mkdir /home/public
  chmod 777 /home/public

在etc/samba/smb.conf中增加:

[share]
        comment = Galen's Share
        path = /home/public
        writable = yes
        valid users = your_username          # 你可以运行 whoami 查看你的用户名


#setsebool -P samba_enable_home_dirs on命令解除selinux对samba的限制。


配置好后,重启samba (sudo systemctl restart smb.service)


关闭 防火墙

sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service


停止SELinux(如果不需要它)


vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#
enforcing - SELinux security policy is enforced. 
# permissive - SELinux prints warnings instead of enforcing. 
# disabled - SELinux is fully disabled. 
SELINUX= disabled # change here


# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected. 
# strict - Full SELinux protection. 
SELINUXTYPE=targeted

sestatus -v可以查看selinux状态。

getenforce也可以。

setenforce命令可以临时关闭selinux,不需要重启。

在windows端:

通过命令行输入IP地址就可以访问对应的共享文件夹。

(WIN7采用NTLMv2认证,需要经过一些设置:


    开始->运行->secpol.msc->本地策略->安全选项->网络安全:LAN管理器身份验证级别->发送 LM 和 NTLMv2 ,如果已协商,则使用NTLMv2 (会话安全 &)->完成设置。


systemctl list-unit-files命令用于查看服务状态。


0 0