当前位置:首页 > CN2资讯 > 正文内容

centos连接windows服务器

8小时前CN2资讯


一、 FTP 概念

文件传输协议(File Transfer Protoco)是用于在网络上进行文件传输的一套标准协议,使用客户/服务器模式!FTP是用户普遍使用的工具!

二、FTP软件的安装(vsftpd)

1、rpm -qa | grep vsftpd  检查系统中是否安装vsftpd软件

2、yum install -y vsftpd   yum安装vsftpd

3、yum info vsftpd     查看vsftp软件信息

4、chkconfig vsftpd on  将vsftpd 设置为开机启动服务

5、chkconfig --list | grep vsftpd   确认vsftp服务是否为开机启动服务!;

三、配置FTP,配置文件保存在 :  /etc/vsftpd/vsftpd.conf

1、在配置FTP前,先将FTP配置文件进行本地备份,以便还原

首先我们在不修改任何配置文件的时候,将vsftpd服务进行启动,默认启动后支持用户宿主目录访问及匿名用户访问!FTP IP:10.67.51.39

在不知用户的情况下,可使用系统默认生成的ftp用户,或anonymous 两个系统默认用户!不需输入密码,便可直接登陆!

这样我们ftp目录 : /var/ftp 下的文件夹,即为默认目录,我们看到chen 和 pub 两个FTP目录!

     

2、匿名FTP的应用

应用:匿名FTP 往往用来提供一些公共文档,我们提供的文档,大家够可以访问的!

匿名FTP用户名: ftp   anonymous

密码:直接回车  

默认目的:ftp为用户的宿主目录 :  /var/ftp

配置/etc/vsftpd/vsftpd.conf


anonymous_enable=YES #配置文件默认开启匿名服务 #anon_upload_enable=YES #匿名访问不支持上传文件功能,此权限不给匿名用户开放 #anon_mkdir_write_enable=YES #不允许创建目录 xferlog_enable=YES #是否启用日志功能 #xferlog_file=/var/log/xferlog #日志文件统一存放目录,默认不开启,需手动开启,取消#,统一方便管理!日志记录: xferlog_std_format=YES #日志文件记录格式 (这里为标准格式std) #ftpd_banner=Welcome to blah FTP service. 设置登录FTP的欢迎信息,默认不开启,需手动开启,欢迎信息,自己意愿填写!这里系诶什么,登录界面显示什么! anon_max_rate=100000 #设置匿名用户最大传输速率为100KB/s,默认无,可填写在配置文件最后,新增一行,可作为匿名用户下载限制开启


处系统默认配置,其他配置按照上面进行修改,基本实现匿名用户的登陆!


[root@zabbix ftp]# grep -v "^#" /etc/vsftpd/vsftpd.conf anonymous_enable=YES local_enable=YES write_enable=YES local_umask=022 dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES xferlog_file=/var/log/xferlog xferlog_std_format=YES ftpd_banner=Welcome to blah FTP service. listen=YES pam_service_name=vsftpd userlist_enable=YES tcp_wrappers=YES anon_max_rate=100000


下面普及一下 常用FTP命令

(1)、ftp ftp地址  连接FTP服务器,登陆FTP

ftp>

(2)、ls - 查看目录下文件

(3)、cd - 切换目录(FTP)

(4)、bin - 二进制传输

(5)、lcd  切换下载目录(本地)

(6)、get - 下载单个文件

(7)、mget - 下载多个文件

(8)、put - 上传单个文件

(9)、mput - 上传多个文件

(10)、prompt - 关闭监护询问模式,如下载文件夹内多有文件,不用单个文件进行一一确认!

(11)、bye - 退出

(12)、open - 连接FTP服务器

(13)、user - 输入FTP服务器用户名和密码

以上命令,可进行自动化FTP脚本的运行,用来编译自动化运行脚本!

自动化进行FTP下载 : ftp -n < 脚本名称

下面简单举例,创建 ftp.auto自动化下载

1、创建脚本,并创建本地下载目录


[root@rhel ~]# vim ftp.auto open 10.67.51.39 #连接FTP user ftp 1 #用户名,密码 bin #修改传输默认,二进制传输 prompt #关闭交互模式 lcd /ftp.bak #建立下载到本地的目录 mget pub/* #下载目录下的所有文件 bye #退出下载


mkdir /ftp.bak

我们在FTP服务器中创建几个文件,便于测试!

2、进行测试

ftp -n < ftp.auto   下载FTP中内容,也可配置任务排程,定期下载! 

四、用户访问模式

默认系统用户可以登陆,可以登陆centos 系统的用户,就可登陆FTP

我这边创建了两个用户分别为zhangsan、lisi两个用户

在/etc/passwd 中查看两个用户

 

现在我们可以通过这两个用户直接登陆FTP,是可以验证成功!默认普通用户可以登陆!看到的是自己宿主目录下的文件!

 

      

默认情况下支持文件的上传的下载,在windows 下直接拖拽就可!就可上传至用户的宿主目录,我们可以进入 /home/lisi 目录下查看我们上传的文件内容!

    

配置文件,开启vsftpd,FTP用户为系统用户!

如启用SElinux允许用户上传文件到宿主目录,执行如下命令,不然本地用户无法上传文件至宿主目录

setsebool -P ftp_home_dir 1

setsebool -P allow_ftpd_full_access 1

或关闭SElinux

vi /etc/selinux/config   为disable


# 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 #启用本地用户登录,可以登陆本地服务器的用户,即可登陆FTP服务器 # # 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 # # The target log file can be vsftpd_log_file or xferlog_file. # This depends on setting xferlog_std_format parameter xferlog_enable=YES #日志管理权限开放 # # Make sure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES # # 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 # # The name of log file when xferlog_enable=YES and xferlog_std_format=YES # WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log xferlog_file=/var/log/xferlog # # Switches between logging into vsftpd_log_file and xferlog_file files. # NO writes to vsftpd_log_file, YES to xferlog_file xferlog_std_format=YES # # 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_local_user=YES #chroot_local_user=YES #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 listen_port=端口号 #1024以上端口,默认端口20、21,可修改服务端口! # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES pam_service_name=vsftpd userlist_enable=YES userlist_deny=NO userlist_file=/etc/vsftpd.user_list 用户访问管理配置 tcp_wrappers=YES local_max_rate=200000 #本地用户定义用户最大传输速率 anon_max_rate=100000 #限制匿名用户传输速率 max_clients=50 #服务器的总的并发连接数,同时允许多少连接存在 max_per_ip=x #每个IP同时打开几个连接


用户访问控制,限制策略

添加以下配置至配置文件,两种方式

1、限制指定的用户不能访问,而其他用户可以访问

userlist_enable=YES     开启用户访问限制功能 ,默认选项

userlist_deny=YES        拒绝指定用户访问

userlist_file=/etc/vsftpd/user_list    定义指定用户文件

2、限制指定的用户可以访问,而其他用户不可以访问

userlist_enable=YES       开启用户访问限制功能 ,默认选项

userlist_deny=NO           允许指定用户访问,开启

userlist_file=/etc/vsftpd.user_list        定义指定用户文件,格式每个用户名为一行

 

限制用户只能访问自己的宿主目录,不能进行目录切换,可对不同用户进行授权,精细化管理!

chroot_local_user=YES    只能访问 宿主目录,宿主目录变成根目录,无法切换目录

chroot_list_enable=YES         开启用户定力列表功能

chroot_list_file=/etc/vsftpd/chroot    定义不执行chroot的列表

用户有目录的 X 权限,就可以修改目录的内容,有修改目录的权限!

 

 

以上就完成FTP的配置选项!


    你可能想看:

    扫描二维码推送至手机访问。

    版权声明:本文由皇冠云发布,如需转载请注明出处。

    本文链接:https://www.idchg.com/info/29927.html

    分享给朋友:

    “centos连接windows服务器” 的相关文章

    VPS在线测速:如何选择合适的虚拟专用服务器

    在现今的网络环境中,选择合适的VPS(虚拟专用服务器)是每位用户尤其是中小企业和开发者需要重点关注的事项之一。VPS在线测速的重要性体现在很多方面,尤其是在评估服务性能时,测速显得尤为关键。通过测速脚本,用户可以全面了解VPS的网络状况和系统性能,从而在购买时做出更明智的决策。 想象一下,你已经在选...

    如何选择RN套餐性价比高的VPS服务

    RN套餐概述 在谈论RackNerd之前,我想先简单介绍一下这家公司。RackNerd成立于2019年,它是一家专注于虚拟主机和VPS服务的商家。作为市场中的新兴参与者,RackNerd凭借其高性价比迅速赢得了不少用户的青睐。在我了解的多家VPS提供商中,RackNerd以其实惠的价格和稳定的性能脱...

    专业网站被墙检测工具及应对措施攻略

    网站被墙检测工具概述 网络环境的日益复杂,使得网站被墙的问题变得越来越普遍。这种封锁不仅影响了网站的访问量,还可能损害企业的形象和信誉。了解网站被墙的定义及其影响,是我们拥有更好网络体验的基础。 网站被墙,简单来说,指的是某些网站因各种政策或技术原因,无法在特定地区被访问的现象。这种情况会导致用户无...

    深入了解DC9飞机的历史、技术特点与运营经验

    DC9概述 了解DC9这款飞机,首先得从它的历史说起。DC9,或称道格拉斯DC-9,是由道格拉斯飞机公司设计制造的中短程单通道喷气式客机。这款飞机的诞生可以追溯到20世纪60年代。道格拉斯公司在这段时间逐步崛起,骄傲地推出了DC9作为回应当时日益增长的民航市场需求。最初的设计版本虽然体积不大,但凭借...

    UCloud服务器性能与安全性的全面评测

    UCloud服务器概述 UCloud是一家专注于云计算服务的公司,提供多样的云服务器选项,适合不同业务需求。它不仅满足基本的计算、存储和网络功能,还在高可用性、高性能和安全性上表现出色。通过细致的产品设计,UCloud确保每一位用户都能在稳定的环境中运作,充分利用其提供的技术优势。 在使用UClou...

    深入探讨4C与1C:市场营销与电池性能优化的关键

    4C与1C概述 在探讨市场和技术发展的过程中,4C与1C是两个值得注意的概念。虽然它们的名称很相似,但是一个关注的是市场营销的策略,另一个则关乎电池的充放电性能。我常常思考这两个概念的融合点,以及它们对我们生活的深远影响。 1.1 4C理论介绍 4C理论是市场营销中一个重要的框架,帮助企业更好地理解...