centos winbind,windows远程centos

大家好,centos winbind相信很多的网友都不是很明白,包括windows远程centos也是一样,不过没有关系,接下来就来为大家分享关于centos winbind和windows远程centos的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧!

怎么把文件传进虚拟机Vmware中的Red Hat Linux 9.0系统

可以启用samba。

一、安装前准备

1、使用Samba服务器需要防火墙开放以下端口

UDP 137 UDP 138 TCP 139 TCP 445

#配置防火墙端口

[root@roothomes~] vi/etc/sysconfig/iptables

-A INPUT-m state--state NEW-m tcp-p tcp--dport 139-j ACCEPT

-A INPUT-m state--state NEW-m tcp-p tcp--dport 445-j ACCEPT

-A INPUT-m state--state NEW-m udp-p udp--dport 137-j ACCEPT

-A INPUT-m state--state NEW-m udp-p udp--dport 138-j ACCEPT

#重启防火墙,使规则生效

[root@roothomes~]/etc/rc.d/init.d/iptables restart

2、关闭CentOS6系统的 SELinux

[root@roothomes~] vi/etc/selinux/config

#SELINUX=enforcing#注释掉

#SELINUXTYPE=targeted#注释掉

SELINUX=disabled#增加

#:wq保存。

#重启系统

[root@roothomes~] shutdown-r now或者 init 6

二、安装Samba

1、检查Samba服务包是否已安装

[root@roothomes~] rpm-qa| grep samba

samba-3.5.4-68.el6.x86_64

samba-common-3.5.4-68.el6.x86_64

samba-client-3.5.4-68.el6.x86_64

samba4-libs-4.0.0-23.alpha11.el6.x86_64

samba-winbind-clients-3.5.4-68.el6.x86_64

说明samba已经安装,如果没有安装,运行下面命令安装 [root@roothomes~] yum install samba

2、配置samba

[root@roothomes~] chkconfig smb on#设置 Samba开机自动启动

[root@roothomes~] service smb start#启动Samba服务

[root@roothomes~]/etc/init.d/smb restart#重启

[root@roothomes~]/etc/init.d/smb stop#停止

[root@roothomes~] cp/etc/samba/smb.conf/etc/samba/bak_smb.conf_bak#备份

[root@roothomes~] cp/etc/samba/bak_smb.conf_bak/etc/samba/smb.conf#恢复

[root@roothomes~] vi/etc/samba/smb.conf

[global]#找到这一行(全局设置标签),在此行下面添加如下行:

workgroup= WORKGROUP#工作组名称改为 Windows网络所定义的工作组名

server string= Samba Server#设置samba服务器的主机名称

security= user#设置samba服务器安全级别为user,即以账号和口令访问

netbios name= SambaServer#设置Samba服务器访问别名

#在配置文件的末尾添加以下自定义内容

[SambaServer]#在Windows网上邻居中看到的共享目录的名字

comment= SambaServer#在Windows网上邻居中看到的共享目录的备注信息

path=/home/SambaServer#共享目录在系统中的位置

public= no#不公开目录

writable= yes#共享目录可以读写

valid users=SambaServer#只允许SambaServer用户访问

#保存配置

3、添加访问linux共享目录的账号SambaServer

用户家目录为/home/SambaServer,用户登录终端设为/bin/false(即使之不能登录系统)

[root@roothomes~] mkdir-p/home/SambaServer#建立SambaServer文件夹

[root@roothomes~] cd/home/SambaServer

[root@roothomes~] touch samba.txt#创建测试文件samba.txt

[root@roothomes~] useradd SambaServer-d/home/SambaServer-s/bin/false

[root@roothomes~] chown SambaServer:SambaServer/home/SambaServer-R

4、将用户SambaServer添加入到Samba用户数据库,并设置登录共享目录的密码为:123456

[root@roothomes~] smbpasswd-a SambaServer

New SMB password:输入该用户用于登录Samba的密码

Retype new SMB password:再次确认输入该密码

Added user SambaServer.

#备注:这里设置的密码是SambaServer用户登录该机的Samba共享的密码,非登陆OS的密码;

5、重启Samba服务器

[root@roothomes~]/etc/init.d/smb restart

6、浏览共享信息

在Windows客户端输入\\ip或者\\SambaServer#服务器别名

回车之后,会跳出来登录框,输入账号SambaServer,密码123456,即可访问共享目录

问题:

如果无法访问共享目录的内容,请把防火墙停止;

[root@roothomes~] service iptables stop

如何配置samba服务器

系统环境:

系统平台:CentOS release 6.3(Final)

Samba版本:samba-3.5.10-125.el6.x86_64

Samba Server IP:10.0.0.163

防火墙已关闭/iptables: Firewall is not running.

SELINUX=disabled

安装Samba服务:

1、在可以联网的机器上使用yum工具安装,如果未联网,则挂载系统光盘进行安装。

#yuminstallsambasamba-clientsamba-swat

有依赖关系的包samba-common、samba-winbind-clients、libsmbclient将自动安装上去。

2、查看安装状况

3、安装包说明

samba-common-3.5.10-125.el6.x86_64//主要提供samba服务器的设置文件与设置文件语法检验程序testparm

samba-client-3.5.10-125.el6.x86_64//客户端软件,主要提供linux主机作为客户端时,所需要的工具指令集

samba-swat-3.5.10-125.el6.x86_64//基于https协议的samba服务器web配置界面

samba-3.5.10-125.el6.x86_64//服务器端软件,主要提供samba服务器的守护程序,共享文档,日志的轮替,开机默认选项

Samba服务器安装完毕,会生成配置文件目录/etc/samba和其它一些samba可执行命令工具,/etc/samba/smb.conf是samba的核心配置文件,/etc/init.d/smb是samba的启动/关闭文件。

4、启动Samba服务器

可以通过/etc/init.d/smb start/stop/restart来启动、关闭、重启Samba服务,启动SMB服务

5、查看samba的服务启动情况

#servicesmbstatus

6、设置开机自启动

#chkconfig--level35smbon//在3、5级别上自动运行samba服务

selinux常用参数

了解和配置 SELinux

1.获取当前 SELinux运行状态

getenforce

可能返回结果有三种:Enforcing、Permissive和 Disabled。Disabled代表 SELinux被禁用,Permissive代表仅记录安全警告但不阻止可疑行为,Enforcing代表记录警告且阻止可疑行为。

目前常见发行版中,RHEL、CentOS、Fedora等默认设置为 Enforcing,其余的如 openSUSE等为 Permissive。

2.改变 SELinux运行状态

setenforce [ Enforcing| Permissive| 1| 0 ]

该命令可以立刻改变 SELinux运行状态,在 Enforcing和 Permissive之间切换,结果保持至关机。一个典型的用途是看看到底是不是 SELinux导致某个服务或者程序无法运行。若是在 setenforce 0之后服务或者程序依然无法运行,那么就可以肯定不是 SELinux导致的。

若是想要永久变更系统 SELinux运行环境,可以通过更改配置文件/etc/selinux/config实现。注意当从 Disabled切换到 Permissive或者 Enforcing模式后需要重启计算机并为整个文件系统重新创建安全标签(touch/.autorelabel&& reboot)。

[root@web2~]# vim/etc/selinux/config

# 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- No SELinux policy is loaded.

SELINUX=enforcing

# SELINUXTYPE= can take one of these two values:

# targeted- Targeted processes are protected,

# mls- Multi Level Security protection.

SELINUXTYPE=targeted

3. SELinux运行策略

配置文件/etc/selinux/config还包含了 SELinux运行策略的信息,通过改变变量 SELINUXTYPE的值实现,该值有两种可能: targeted代表仅针对预制的几种网络服务和访问请求使用 SELinux保护,strict代表所有网络服务和访问请求都要经过 SELinux。

RHEL、CentOS、Fedora等默认设置为 targeted,包含了对几乎所有常见网络服务的 SELinux策略配置,已经默认安装并且可以无需修改直接使用。若是想自己编辑 SELinux策略,也提供了命令行下的策略编辑器 seedit以及 Eclipse下的编辑插件 eclipse-slide。

4. coreutils工具的 SELinux模式

常见的属于 coreutils的工具如 ps、ls等等,可以通过增加 Z选项的方式获知 SELinux方面的信息。

4.1使用ps获取:

[barlow@web1~]$ ps-auxZ|grep httpd|head-5

Warning: bad syntax, perhaps a bogus'-'? See/usr/share/doc/procps-3.2.8/FAQ unconfined_u:system_r:httpd_t:s0 apache 1393 0.0 0.2 279648 2272? S Jun27 0:01/usr/sbin/httpd unconfined_u:system_r:httpd_t:s0 apache 1395 0.0 1.5 272964 15528? S Jun27 0:02/usr/sbin/httpd unconfined_u:system_r:httpd_t:s0 apache 1399 0.0 1.7 272964 17828? S Jun27 0:02/usr/sbin/httpd unconfined_u:system_r:httpd_t:s0 apache 1405 0.0 1.2 272964 12732? S Jun27 0:02/usr/sbin/httpd unconfined_u:system_r:httpd_t:s0 apache 1409 0.0 1.4 272968 14784? S Jun27 0:03/usr/sbin/httpd

4.2使用ls获取

[barlow@web1~]$ ls-Z/var/www/ drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_content_t:s0 error drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_content_t:s0 html drwxrwxrwx. apache barlow unconfined_u:object_r:httpd_sys_content_t:s0 icons drwxrwxrwx. apache barlow system_u:object_r:httpd_sys_content_t:s0 lost+found

以此类推,Z选项可以应用在几乎全部 coreutils工具里。

5、常用修改有关httpd服务的SELinux策略方法:

如上,ls-Z方法查询到的文件SELinux上下文跟默认要求的不匹配,则服务无法正常使用,如SELinux要求httpd服务的网页目录或文件的上下文要为httpd_sys_content_t,否则客户端无法访问。

5.1使用chcon修改httpd目录或文件安全上下文:

如nagios服务器的网页目录上下文默认为unconfined_u:object_r:usr_t:s0,则客户端无法访问:

[root@nagios~]# ll-Z/usr/local/nagios/share/

-rwxrwxr-x. nagios apache system_u:object_r:usr_t:s0 config.inc.php

drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 contexthelp

drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 docs

drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 images

drwxrwxr-x. nagios apache unconfined_u:object_r:usr_t:s0 includes

-rwxrwxr-x. nagios apache system_u:object_r:usr_t:s0 index.html

-rwxrwxr-x. nagios apache system_u:object_r:usr_t:s0 index.php

……以下略……

使用chcon修改/usr/local/nagios/share/目录及其下所有文件安全上下文为unconfined_u:object_r:httpd_sys_content_t

[root@nagios~]# chcon-R unconfined_u:object_r:httpd_sys_content_t:s0/usr/local/nagios/share/

查询结果:

[root@nagios~]# ls-Z/usr/local/nagios/share/

-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 config.inc.php

drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 contexthelp

drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 docs

drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 images

drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 includes

-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 index.html

-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 index.php

drwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 locale

-rwxrwxr-x. nagios apache unconfined_u:object_r:httpd_sys_content_t:s0 main.html

不用重启httpd服务,客户端就已经可以访问。

5.2使用semanage工具,让httpd支持非标准端口:

semanage工具非常强大,基本能实现所有SELinux配置,但很多时候我们并不知道SELinux错在哪里,在图形界面下有图形化的分析工具,在终端界面下也有一个功能非常强大的分析工具sealert,但默认情况下,这两个工具都没有被安装,需要先安装semanage和sealert工具:

[root@web2~]# yum-y install policycoreutils-python setroubleshoot

注:semanage的使用也可以参见我的另外一篇博文:Selinux管理工具semanage。

默认情况下 Apache只侦听 80、443等几个端口,若是直接指定其侦听 808端口的话,会在 service httpd restart的时候报错:

[root@web2~]# service httpd start

正在启动 httpd:(13)Permission denied: make_sock: could not bind to address 0.0.0.0:808

no listening sockets available, shutting down

Unable to open logs [失败]

查看/var/log/messages文件,可以看到如下这样的错误:

[root@web2~]# tail/var/log/messages

Jun 29 10:30:51 web2 setroubleshoot: SELinux is preventing/usr/sbin/httpd from name_bind access on the tcp_socket. For complete SELinux messages. run sealert-l 2ad073a4-7c64-4175-93ff-9d78f75133af

根据提示,运行sealert-l 2ad073a4-7c64-4175-93ff-9d78f75133af,生成SELinux报告如下:

[root@web2~]# sealert-l 2ad073a4-7c64-4175-93ff-9d78f75133af

# semanage port-a-t PORT_TYPE-p tcp 808

其中 PORT_TYPE是以下之一:ntop_port_t, http_cache_port_t, http_port_t, puppet_port_t, jboss_messaging_port_t, jboss_management_port_t。

根据提示,运行semanage port-a-t PORT_TYPE-p tcp 808,此处需将PORT_TYPE替换为 http_port_t

[root@web2~]# semanage port-a-t http_port_t-p tcp 808

查询结果:

[root@web2~]# semanage port-l|grep http

http_cache_port_t tcp 3128, 8080, 8118, 8123, 10001-10010

http_cache_port_t udp 3130

http_port_t tcp 808, 80, 443, 488, 8008, 8009, 8443##可以看到808端口已经加入

pegasus_http_port_t tcp 5988

pegasus_https_port_t tcp 5989

重启服务:

[root@web2~]# service httpd start

正在启动 httpd: [确定]

5.3修改selinux布尔值,允许创建私人网站

若是希望用户可以通过在~/www/放置文件的方式创建自己的个人网站的话,那么需要在 Apache策略中允许该操作执行。使用:

[root@web2~]# setsebool httpd_enable_homedirs 1

默认情况下 setsebool的设置只保留到下一次重启之前,若是想永久生效的话,需要添加-P参数,比如:

[root@web2~]# setsebool-P httpd_enable_homedirs 1

setsebool是用来切换由布尔值控制的 SELinux策略的,当前布尔值策略的状态可以通过 getsebool来获知。查看与httpd相关的布尔值:

[root@web2~]# getsebool-a|grep http

allow_httpd_anon_write--> off

allow_httpd_mod_auth_ntlm_winbind--> off

allow_httpd_mod_auth_pam--> off

allow_httpd_sys_script_anon_write--> off

httpd_builtin_scripting--> on

httpd_can_check_spam--> off

httpd_can_network_connect--> off

httpd_can_network_connect_cobbler--> off

httpd_can_network_connect_db--> on

httpd_can_network_memcache--> off

httpd_can_network_relay--> off

httpd_can_sendmail--> off

httpd_dbus_avahi--> on

httpd_enable_cgi--> on

httpd_enable_ftp_server--> off

httpd_enable_homedirs--> on

httpd_execmem--> off

httpd_manage_ipa--> off

httpd_read_user_content--> off

httpd_run_stickshift--> off

httpd_setrlimit--> off

httpd_ssi_exec--> off

httpd_tmp_exec--> off

httpd_tty_comm--> on

httpd_unified--> on

httpd_use_cifs--> off

httpd_use_gpg--> off

httpd_use_nfs--> on

httpd_use_openstack--> off

httpd_verify_dns--> off

named_bind_http_port--> off

以上列举了

阅读剩余
THE END