redhat网络安装系统 之二

本文涉及的产品
运维安全中心(堡垒机),免费版 6个月
日志服务 SLS,月写入数据量 50GB 1个月
简介: 3、 配置TFTP服务器     TFTP(Trivial File Transfer Protocol简朴文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。

3、 配置TFTP服务器

    TFTP(Trivial File Transfer Protocol简朴文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务TFTP承载在UDP上,提供不可靠的数据流传输服务,不提供存取授权与认证机制,使用超时重传方式来保证数据的到达。与FTP相比,TFTP的大小要小的多,TFTP是用来下载远程文件的最简单网络协议,它基于UDP协议而实现。它使用的是UDP的69端口 。

配置TFTP服务器主要用途是为了能够给客户端传送bootstrap程序[pxelinux.0]这样才能够让客户端进行引导加载内核映象文件(vmlinuz)和根文件系统文件(initrd.img)以及启动内核(Kernel)

1、 TFTP的配置文件

先用rpm -qa |grep tftp 确定系统上是否装了TFTP(如果返回一个安装包的名字,说明已经安装了,参数 -a 表示已经装了的程序包)。如果没有,就去安装镜像里安装:tftp-server-0.42-3.1 程序包。如果安装了,修改/etc/xinetd.d/tftp  

TFTP的配置文件为 /etc/xinetd.d/tftp

 配置内容如下:

 #default off

#descriptionThe tftp server serves files using the trivialfiletransfer \

#protocol. The tftp protocol is often used to bootdiskless \

#workstations, download configuration files tonetwork-awareprinters, \

#and to start the installation process for someoperatingsystems.

service tftp

{

        disable= no

       socket_type            = dgram

       protocol               = udp

#      protocol               = tcp

       wait                   = yes

       user                   = root

       server                 = /usr/sbin/in.tftpd

       server_args            = -u nobody -s /tftpboot                         #指定TFTP的根目录所在位置,允许任何用户可以进行访问参数-s指定chroot,-c指定了可以创立文件

       per_source             = 11

       cps                    = 100 2

       flags                  = IPv4

}

在这里主要修改的字段是disable ,yes改为no。以打开TFTP服务


2、启动TFTP服务

 #service xinetd restart

 

附加:(以下操作与本次安装无关,仅作扩展练习)创立tftp根目录,关闭防火墙,启动tftp-server

[root@wk ~]# mkdir /tftpboot

[root@wk ~]# chmod -R 777 /tftpboot

[root@wk ~]# /etc/init.d/iptables stop

[root@wk ~]# service xinetd restart

重启xinetd服务,因为TFTP服务受控与xinetd服务,xinetd是管服务的服务,它是不开端口的。

所以要验证一下TFTP是否开启69端口起来了:

[root@wk ~]# netstat -nlp

2.udp 0 0 0.0.0.0:67 0.0.0.0:* 5172/dnsmasq

3.udp 0 0 0.0.0.0:67 0.0.0.0:* 4745/dhcpd

4.udp 0 0 0.0.0.0:69 0.0.0.0:* 6171/xinetd

5.udp 0 0 0.0.0.0:994 0.0.0.0:* 4633/rpc.rquotad

如何测试 tftp 是否成功开启?

在 tftp 目录下创建一个文件,比如 1.txt 。
在 Shell 中连接 tftp 服务:

tftp 127.0.0.1

我擦,显示:command not  found 。。。咋回事呢?原来在本机上还要装tftp客户端,就是这个包:tftp-0.42-3.1.i386.rpm也在镜像中找。。然后在运行:

tftp 127.0.01


tftp>get 1.txt

若服务成功开启,则能看到成功下载文件的提示。并在当前目录下找到1.txt文件。

ftp>help   ——查看命令。

tftp>q        ——和quit一样,标识退出,但是没有exit这个命令。


4、配置FTP服务器

    配置FTP服务器主要用途是为了能够给客户端传送Linux的配置环境与安装程序。安装是选择ftp的方式,ftp服务器是192.168.0.15

启动后利用匿名账户进行测试,如果测试成功您就可以将RHEL45张光盘中的所有安装文件全部拷贝到匿名用户的文件夹/var/ftp/目录下。注意:如果用anonymous,则ftp的路径就是“/”,如果用non-anonymous,例如用root,则ftp的路径是“/var/ftp”,需要把整个安装光盘拷贝到/var/ftp路径下。

 

1.准备工作

要运行FTP服务,先要安装FTP服务的服务器软件包.:

在RHEL4中,该软件包在 disc 1中,包名为 : vsftpd-2.0.1-5.i386.rpm

在RHEL5中镜像中的Server程序包中即可找到包[root@linux01 Server]# ls | grep vsftpd* # 查询当前路径下安装包

rpm -ivh vsftpd-2.0.1-5.i386.rpm     //安装该软件包,在var目录下生成目录ftp/pub

正确安装软件包后,就可以对FTP服务器的主配置文件进行修改了

root@linux01 Server]# rpm -qa | grep ^vsftpd  # 再次查询相关已经安装的软件包
vsftpd-2.0.5-12.el5
root@linux01 ~]# rpm -ql vsftpd | grep etc  # 查询etc中与vsftpd相关的文件
/etc/logrotate.d/vsftpd.log
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh


2.修改FTP服务器的主配置文件/etc/vsftpd/vsftpd.conf

该配置文件是在安装软件包的时候自动生成的,不要我们手动建立,我们只需要对它做必要的修改就可以让FTP服务器正常运行了.修改示例如下

[root@linux01 Server]# cat /etc/vsftpd/vsftpd.conf        # 读取原文,默认配置

# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES  # 允许匿名登录
#
# Uncomment this to allow local users to log in.
local_enable=YES  # 允许本地帐户登录
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES  # 开放对本地用户的写权限
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022  # 本地用户的文件生成掩码
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES  # 显示目录下的.message
#
# Activate logging of uploads/downloads.
xferlog_enable=YES  # 启用上传和下载日志
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES  # 启用FTP数据端口
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES  # 使用标准的ftpd xferlog日志格式
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES  # FTP服务器处于独立启动模式(相对于受xinnetd管理的启动模式)
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
pam_service_name=vsftpd  # PAM认证服务的配置文件名称,/etc/pam.d/vsftpd
userlist_enable=YES  # FTP将检查userlist_file(/etc/vsftpd/user_list)中用户是否可以访问FTP服务器
tcp_wrappers=YES  # 使用tcp_wrappers作为主机访问控制方式,/etc/host.allow和/etc/hosts.deny。

精简一下没有注释的版本:(其实我没找到要修改的,压根就没改动)

anonymous_enable=YES             //是否允许匿名访问,匿名帐户为 ftp和 anonymous

local_enable=YES                 //是否允许本地用户访问

write_enable=YES                 //允许本地用户访问时,是否允许他们有写入的权限

local_umask=022                  //本地用户在写入文件时,这些文件默认的权限

dirmessage_enable=YES

xferlog_enable=YES                //是否启用日志

xferlog_std_format=YES            //是否用标准格式存储日志

connected_from_port_20=YES       //是否允许从20的连接请求

pam_service_name=vsftpd          //设置PAM认证服务的配置文件名,该文件位于/etc/pam.d目录下

listen=YES                      //FTP处于独立启动模式

tcp_wraapers=YES                //该服务器使用tcp_wrappers作为主机访问控制方式

userlist_enable=YES             //是否检查vsftpd.user_list中的设置,该文件在/etc下.(在RHEL5中

                                  该文件位于/etc/vsftpd中,文件名为user_list

userlist_deny=YES               //该项与上一项一起构成了黑名单,即在vsftpd.user_list中的用户不

                                  允许访问该FTP服务器.当该项设置为NO时,vsftpd.user_list则为白

                                  名单,即只允许在vsftpd.user_list中的用户访问该FTP服务器.

chroot_local_user=YES             //本地用户登陆时,将其禁锢在FTP根目录下

chroot_list_file=/etc/vsftpd/chroot_list         //该项和上一项配合使用,当该项不存在时,设置上

                                                  一项为YES后,则所有本地用户都被禁锢在FTP根

                                                目录下,该项存在时,则只有该文件中的用户被禁锢

max_clients=100                 //FTP服务器的最大并发连接数

max_per_ip=5                    //每个ip最多建5个连接

local_max_rate=50000                  //本地用户的最大传输速率,单位为B/s

anon_max_rate=10000                    //匿名用户的最大传输速率,单位为B/s

 

3.启动vsftpd,运行FTP服务

service vsftpd restart

如果想让FTP服务器在系统启动时就提供服务,则需要修改其在系统级别下的运行 状态

chkconfig --list vsftpd         //查看在不同系统级别下,vsftpd的运行状态

chkconfig --level 35 vsftpd on   //设置vsftpd在3 5 系统级别下自动运行

简单的FTP服务配置就完成了,在FTP配置过程中,FTP的主配置文件中有启用匿名帐户写入权限项,但是无论该项如何设置都不能让匿名登陆帐户有写入权限.

 

附加:(仅作为额外练习) /etc/vsftpd.user_list文件配置
[root@linux01 ~]# cd /etc/vsftpd
root@linux01 vsftpd]# ls
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@linux01 vsftpd]# cat user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
[root@linux01 vsftpd]#
(当vsftp.conf配置文件中包括以下配置时,user_list中用户帐号禁止登录配置: (黑名单功能)
userlist_enable=YES # 注意大小写
userlist_deny=YES  

当vsftp.conf配置文件中包括以下配置时,只有user_list中用户帐号允许登录配置:注意考虑ftpusers文件用户(白名单功能,只有在此表中的用户可以访问,其他的人都不可以)
userlist_enable=YES # 注意大小写
userlist_deny=NO

)
[root@linux01 vsftpd]# cat ftpusers
# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
[root@linux01 vsftpd]#
4、匿名用户登录目录
匿名用户将进入/var/ftp目录

更加详细的ftp操作请参照:http://blog.csdn.net/changyanmanman/article/details/7646307

相关文章
|
1天前
|
机器学习/深度学习 算法 TensorFlow
动物识别系统Python+卷积神经网络算法+TensorFlow+人工智能+图像识别+计算机毕业设计项目
动物识别系统。本项目以Python作为主要编程语言,并基于TensorFlow搭建ResNet50卷积神经网络算法模型,通过收集4种常见的动物图像数据集(猫、狗、鸡、马)然后进行模型训练,得到一个识别精度较高的模型文件,然后保存为本地格式的H5格式文件。再基于Django开发Web网页端操作界面,实现用户上传一张动物图片,识别其名称。
15 1
动物识别系统Python+卷积神经网络算法+TensorFlow+人工智能+图像识别+计算机毕业设计项目
|
2天前
|
负载均衡 网络协议 网络安全
设计一个高性能的网络系统
设计一个高性能的网络系统
14 2
|
21天前
|
传感器 SQL 运维
常见网络安全设备:IPS(入侵防御系统)零基础入门到精通,收藏这一篇就够了
常见网络安全设备:IPS(入侵防御系统)零基础入门到精通,收藏这一篇就够了
53 3
|
28天前
|
监控 网络协议 Linux
在Linux中,如何实时抓取并显示当前系统中tcp 80 端口的网络数据信息?
在Linux中,如何实时抓取并显示当前系统中tcp 80 端口的网络数据信息?
|
6天前
|
云安全 安全 网络安全
探索云计算与网络安全的共生之道在数字化浪潮席卷全球的今天,云计算作为信息技术的一大革新,正重塑着企业的运营模式与服务交付。然而,随着云服务的普及,网络安全与信息安全的挑战也日益凸显,成为制约其发展的关键因素。本文旨在深入探讨云计算环境下的网络安全问题,分析云服务、网络安全及信息安全之间的相互关系,并提出相应的解决策略,以期为构建一个更安全、可靠的云计算生态系统提供参考。
本文聚焦于云计算环境中的网络安全议题,首先界定了云服务的基本概念及其广泛应用领域,随后剖析了当前网络安全面临的主要威胁,如数据泄露、身份盗用等,并强调了信息安全在维护网络空间秩序中的核心地位。通过对现有安全技术和策略的评估,包括加密技术、访问控制、安全审计等,文章指出了这些措施在应对复杂网络攻击时的局限性。最后,提出了一系列加强云计算安全的建议,如采用零信任架构、实施持续的安全监控与自动化响应机制、提升员工的安全意识教育以及制定严格的合规性标准等,旨在为云计算的安全可持续发展提供实践指南。
23 0
|
1月前
|
机器学习/深度学习 数据采集 人工智能
未来的守护神:AI驱动的网络安全之盾,如何用智慧的光芒驱散网络黑暗势力?揭秘高科技防御系统背后的惊天秘密!
【8月更文挑战第13天】随着网络技术的发展,网络安全问题愈发严峻,传统防御手段已显乏力。本文探讨构建AI驱动的自适应网络安全防御系统,该系统能自动调整策略应对未知威胁。通过数据采集、行为分析、威胁识别及响应决策等环节,利用Python工具如Scapy、scikit-learn和TensorFlow实现网络流量监控、异常检测及自动化响应,从而提升网络安全防护的效率和准确性。随着AI技术的进步,未来的网络安全防御将更加智能和自动化。
34 6
|
1月前
|
监控 安全 网络协议
这10款网络扫描工具,是个网工,都想全部安装!
这10款网络扫描工具,是个网工,都想全部安装!
|
1月前
|
Linux
虚拟机安装Linux系统的网络配置
该博客文章提供了解决虚拟机中Linux系统网络问题的多种方法,包括重置网络服务、修改网络配置文件、使用不同网络模式等,以确保虚拟机能够成功连接到网络。
虚拟机安装Linux系统的网络配置
|
27天前
|
网络协议 Linux Shell
【Azure 应用服务】App Service For Linux 中安装paping, 用于验证从App Service向外请求的网络连通性
【Azure 应用服务】App Service For Linux 中安装paping, 用于验证从App Service向外请求的网络连通性
|
1月前
|
存储 Kubernetes 调度
使用 Kubeadm 部署 Kubernetes(K8S) 安装 -- 持久化存储(NFS网络存储)
使用 Kubeadm 部署 Kubernetes(K8S) 安装 -- 持久化存储(NFS网络存储)
43 0

推荐镜像

更多