linux基础(十五)自动装系统和lftp配置

来源:互联网 发布:怎么淘宝放单子 编辑:程序博客网 时间:2024/06/09 20:24

一、kickstart

Kickstart是一种无人值守的安装方式。它的工作原理是提前记录在安装过程中需要的填写的各种参数,并生成一个名为ks.cfg的文件

kickstart通常运用于批量安装系统,

自动安装系统需要完成三个问题:1、配置系统镜像源; 2、配置dhcp分配ip; 3、设置ks.cfg文件,并将这个文件放在网络源上

1、配置系统镜像源

执行批量安装时,需要配置网络yum源,可以用httpd服务

先安装httpd服务

yum install -y httpd

systemctl start httpd

systemctl enable httpd

mkdir /var/www/html/rhel7

将镜像文件挂载到/var/www/html/rhel7中

注意:需要 关闭防火墙

这时,只要能与本机ping通的主机都可以通过http访问到默认发布目录下的 rhel7 文件

2、配置dhcpd服务

首先安装dhcpd服务
yum install -y dhcpd
查找dhcpd安装后产生的文件
rpm -ql dhcpd
将dhcpd的配置文件模版 /usr/share/doc/dhcp-4.2.5/dhcp.conf.example 复制到 /etc/dhcp/dhcpd.conf

vim /etc/dhcp/dhcpd.conf

 更改 域名和域名服务器(DNS)

 7 option domain-name "example.org";
 8 option domain-name-servers ns1.example.org, ns2.example.org;


在第32行设置网段,子网掩码,分配ip的范围,以及route网关

 32 subnet 172.25.254.0 netmask 255.255.255.0 {

 33   range 172.25.254.100 172.25.254.120;
 34   option routers 172.25.254.50;
 35 }

最后关闭防火墙,开启dhcpd服务。

3、设置ks.cfg文件

安装 kickstart 软件


然后在系统工具中打开kickstart

第一栏是基本设置


安装方式设置


启动引导,选择安装一个新的启动引导


设置分区大小,至少设置3个分区


添加网络,并设置dhcp获取


安装一个图形环境


其他都选择默认

保存文件到桌面



最后vim ks.cfg

在最后面加上需要安装的软件包,其中@base 必须安装


可以用ksvalidator 检测文件中的语法错误


将这个文件cp 到 /var/www/html/ 中


4、安装虚拟机


填写网络镜像源和网络ks源



完成后就可以自动安装系统了。

二、vsftpd服务

very secure FTP daemon的缩写,是一种非常安全的文件传输服务

首先安装vsftpd,并开启服务,设置开机启动

注意:提供vsftp服务需要关闭防火墙

yum install vsftpd  -y

systemctl start vsftpd 

systemctl enable vsftpd 

systemctl stop firewalld

systemctl disable firewalld


/etc/vsftpd/vsftpd.conf ##配置文件

/var/ftp/pub/ ##默认发布目录,客户端可以用lftp直接访问到这个目录下的文件 

客户端可以安装lftp 软件,从vsftpd 服务端下载文件

1、匿名登录


lftp  服务端ip

这种方式登录只能访问默认发布目录/var/ftp/pub/

在配置文件中设置如下

 11 # Allow anonymous FTP? (Beware - allowed by default if you comment this out)
 12 anonymous_enable=YES ##允许匿名用户登录,NO为不允许

 29 #anon_upload_enable=YES ##默认不允许匿名用户上传,取消注释则允许
 30 #
 31 # Uncomment this if you want the anonymous FTP user to be able to create
 32 # new directories.
 33 #anon_mkdir_write_enable=YES ##默认不允许匿名用户创建目录,取消注释则允许

2、以本地用户登录

lftp 服务端ip -u 本地用户名 ##需要输入密码

以本地用户登录之后,默认访问该用户的家目录。

 16 local_enable=YES ##本地用户可登录

 19 write_enable=YES ##本地用户可写


  21 # Default umask for local users is 077. You may wish to change this to 022,

  22 # if your users expect that (022 is used by most other ftpd's)

  23 local_umask=022 ##本地用户创建目录时的默认预留权限,默认为077


 94 # You may specify an explicit list of local users to chroot() to their home
 95 # directory. If chroot_local_user is YES, then this list becomes a list of
 96 # users to NOT chroot().

 97 # (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
 98 # the user does not have write access to the top level directory within the
 99 # chroot)
100 chroot_local_user=YES  ##将所有用户限制在主目录。默认情况是NO,即默认不限制
101 chroot_list_enable=YES ##启动例外用户的名单。默认是NO
102 # (default follows)
103 chroot_list_file=/etc/vsftpd/chroot_list ##例外用户名单,当chroot_local_user=YES时,此名单不限制用户在主目录,=NO时,此名单限制用户在主目录。
104 #

3、SELinux

linux安全管理策略

vim /etc/sysconfig/selinux

  2 # This file controls the state of SELinux on the system.
  3 # SELINUX= can take one of these three values:
  4 #     enforcing - SELinux security policy is enforced.                       ##安全管理实行
  5 #     permissive - SELinux prints warnings instead of enforcing.   ##显示警告代替实行
  6 #     disabled - No SELinux policy is loaded.                         ##不实行
  7 SELINUX=disable                                                                
  8 # SELINUXTYPE= can take one of these two values:
  9  #     targeted - Targeted processes are protected,         ##图形
 10 #     minimum - Modification of targeted policy. Only selected processes are protected. 
 11 #     mls - Multi Level Security protection.     ##文本
 12 SELINUXTYPE=targeted

原创粉丝点击