虽然在嵌入式系统中,我们可以通过串口的Xmodem模式传送小的文件,但是毕竟不符合我们的使用习惯,并且串口传输速率太低,不能满足我们大部分的需求,要传输文件的时候,我们还是使用网络较为熟悉,今天我将我的ftp的笔记整理一下,分享给大家。

1.何为FTP

FTP(File Transfer Protocol,文件传输协议)是 TCP/IP 协议组中的协议之一。 FTP 协议包括两个组成部分,其一为 FTP 服务器,其二为 FTP 客户端。其中 FTP 服务器用来存储文件,用户可以使用 FTP客户端通过 FTP 协议访问位于 FTP 服务器上的资源。由于 FTP 传输效率非常高,在网络上传输大的文件时, 经常采用该协议。

默认情况下 FTP 协议使用 TCP 端口中的 20 和 21 这两个端口,其中 20 用于传输数据, 21 用于传输控制信息。但是,是否使用 20 作为传输数据的端口与 FTP 使用的传输模式有关,如果采用主动模式,那么数据传输端口就是 20;如果采用被动模式,则具体最终使用哪个端口要服务器端和客户端协商决定。

vsftpd 则是 very secure FTP daemon 的缩写,它是 UNIX 类操作系统上运行的服务器的名字,它可以运行在诸如 Linux、 BSD、 Solaris、 HP-UNIX 等系统上面,是一个完全免费的、开放源代码的 FTP 服务器软件。

2.ftp 配置

我们今天还是使用OKMX6ULL-s2开发板来举例。

开发板默认已经启动vsftpd服务,我们先看一下配置。

我们看到关于ftp的配置有4个文件,

root@fetmx6ull-s:/etc# more vsftpd.chroot_listrootroot@fetmx6ull-s:/etc#

可以看到,我们ftp默认使用的用户名为root,

root@fetmx6ull-s:/etc# more vsftpd.ftpusers# Users that are not allowed to login via ftprootbindaemonadmlpsyncshutdownhaltmailnewsuucpoperatorgamesnobodyroot@fetmx6ull-s:/etc# more vsftpd.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.rootbindaemonadmlpsyncshutdownhaltmailnewsuucpoperatorgamesnobodyroot@fetmx6ull-s:/etc#root@fetmx6ull-s:/etc# more vsftpd.conf# Example config file /etc/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.# run standalonelisten=YES# 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## Activate logging of uploads/downloads.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## 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 formatxferlog_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=ftp## 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 turning on ascii_download_enable enables malicious remote parties# to consume your I/O resources, by issuing the command "SIZE /big/file" in# ASCII mode.# These ASCII options are split into upload and download because you may wish# to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),# without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be# on the client anyway..#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## This string is the name of the PAM service vsftpd will use.pam_service_name=vsftpd## This option is examined if userlist_enable is activated. If you set this# setting to NO, then users will be denied login  unless  they are  explicitly# listed  in the file specified by userlist_file.  When login is denied, the# denial is issued before the user is asked for a password.userlist_deny=YES## If enabled, vsftpd will load a list of usernames, from the filename given by# userlist_file.  If a user tries to log in using  a  name in  this  file,  they# will be denied before they are asked for a password. This may be useful in# preventing cleartext passwords being transmitted. See also userlist_deny.userlist_enable=NO## If enabled,  vsftpd  will display directory listings with the time in your# local time zone. The default is to display GMT. The times returned by the# MDTM FTP command are also affected by this option.use_localtime=YES## If set to YES, local users will be (by default) placed in a chroot() jail in# their home directory after login.  Warning: This  option has  security # implications,  especially  if  the users have upload permission, or shell access.# Only enable if you know what you are doing.  Note that these security implications# are not vsftpd specific. They apply to all FTP daemons which offer to put# local  users in chroot() jails.chroot_local_user=YES#allow_writeable_chroot=YES#tcp_wrappers=YES

从以上三个文件中,我们可以看到(这里不分析具体的配置说明),可以使用root用户进行ftp的登录,这里对ftp的root账户没有指定口令,所以要使用默认的口令,

修改口令可以使用passwd来完成。

3.连接ftp服务器

我的开发板的地址是192.168.0.232

1)第一种方法使用windows的命令行模式。

我一般喜欢使用win10中的powershell,因为这个是跨平台的,可以支持linux命令;

可以看到,我们已经连接成功了,并且可以看到ftp的根目录是  家目录的地址。

PS C:\Users\Administrator> ftp 192.168.0.232连接到 192.168.0.232。220 (vsFTPd 3.0.3)200 Always in UTF8 mode.用户(192.168.0.232:(none)): root331 Please specify the password.密码:230 Login successful.ftp> ls200 PORT command successful. Consider using PASV.150 Here comes the directory listing.JL2-24.logUSBDrv.infaaauto.shcpu.logcpu1.loginfo.logmem.logmemtestermountdata.shnet.logrun.shstresssysinfo.shtemp.logtm.shtn226 Directory send OK.ftp: 收到 161 字节,用时 0.00秒 40.25千字节/秒。ftp>

从嵌入式系统下载文件

ftp> get auto.sh d:\auto.sh200 PORT command successful. Consider using PASV.150 Opening BINARY mode data connection for auto.sh (33 bytes).226 Transfer complete.ftp: 收到 33 字节,用时 0.00秒 33000.00千字节/秒。

上传文件到嵌入式系统中

ftp> put d:\auto.sh a.sh200 PORT command successful. Consider using PASV.150 Ok to send data.226 Transfer complete.ftp: 发送 33 字节,用时 0.01秒 2.20千字节/秒。ftp>

2)使用工具软件filezilla软件

输入正确的ip地址,用户名 和密码,登录

可以看到,已经登录成功了,并且列出了ftp服务器上的根目录的文件(实际就是家目录下的文件),我们可以对比一下

具体的这个上传下载旧更简单了。不需要在这里啰嗦了。

就写到这里了。欢迎评论,共同提高。。

嵌入式系统学习笔记之ftp相关推荐

  1. 计算机三级之嵌入式系统学习笔记8

    嵌入式系统是嵌入式计算机系统的简称,它是一种嵌入在设备(或系统)内部,为特定应用而设计开发的专用计算机系统 嵌入式系统与通用计算机一样,也由硬件和软件组成 能够按照指令的规定高速度完成二进制数据算数和 ...

  2. 计算机三级之嵌入式系统学习笔记7

    嵌入式系统的开发过程 需求分析与规格说明 系统设计 构件设计 系统集成与测试 嵌入式系统的开发特点 使用宿主机-目标机的开发架构 用于编程.调试的计算机称为宿主机 用于程序最终运行的称为目标机 与底层 ...

  3. 计算机三级之嵌入式系统学习笔记6

    嵌入式系统的软件结构 简单的轮询结构 应用程序重复循环检查每个外部输入条件,一旦有需要处理的任务,则进行相应的处理 带中断的轮询结构(中断驱动结构或前后台结构) 当有外部事件(例如温度传感器报警)发生 ...

  4. 计算机三级之嵌入式系统学习笔记3

    嵌入式最小硬件系统组成: 电源电路 电源模块由以下几部分组成: 交流变直流(AC-DC) 直流到直流(DC-DC) 低压差稳压器(LDO) 时钟电路 复位电路 调试测试接口(JTAG测试接口) 如果处 ...

  5. 计算机三级之嵌入式系统学习笔记1

    嵌入式系统的体系结构按指令集可以分为两大类:复杂指令集结构(CISC)和精简指令集结构(RISC) 嵌入式体系结构按存储机制分为冯诺依曼结构和哈佛结构 冯诺依曼结构中程序和指令并存,共用一条总线:而哈 ...

  6. 嵌入式系统学习笔记之五-- uboot常用命令 概述

    首先,先看看uboot都有那些命令:(这里我使用的是OKMX6ULL-S2开发板的linux版),不同的开发板的系统中的命令可能会稍有差异,对于我们学习影响不大. => help ? - ali ...

  7. 嵌入式系统学习笔记之五-uboot常用命令之补充

    1.nand 命令 uboot 也支持 NAND Flash 的操作命令,现在我们使用的 NAND 版的开发板,进行本节讲解. 输入"help nand"即可查看 NAND 相关命 ...

  8. 嵌入式系统学习笔记之五-- uboot常用命令 环境变量

    uboot 中环境变量的作用就是在不改变源码.不用重新编译的情况下,可以使我们通过设置环境变量的值来改变 uboot 的一些设置.uboot 开机时会一次性从存储介质(启动介质)中读取全部的环境变量到 ...

  9. 计算机三级之嵌入式系统学习笔记5

    基于UART的RS-232/RS-485接口 RS-232 采用标准的RS-232电平转换电路,使UART的电平转换为RS-232电平 无法消除共模干扰,传输距离可达15米 负逻辑传输:逻辑0:+3V ...

最新文章

  1. 关于学习Python的一点学习总结(16->popitem()->sedefault()->update()->values())
  2. matlab 寻找二进制图像边缘
  3. C++11遍历map
  4. 这6个动作,据说只有20%的人能做到!| 今日最佳
  5. 简易投票系统数据库设计
  6. c 语言中fgetc函数,C 库函数 - fgetc()
  7. linux查看端口被哪个服务占用的命令
  8. python之yield
  9. windows应用迁移到linux下
  10. springboot2.x整合Email并利用AOP做一个项目异常通知功能
  11. 【优化算法】未来搜索优化算法(FSA)【含Matlab源码 1448期】
  12. hdjs---后盾网requireJS课程
  13. EXCEL中如何将文本格式的数字转换为日期格式
  14. Open3D Voxelization 体素化
  15. 微信小程序01---小程序初始
  16. 【ES】ES搜索结果中各个字段介绍,hits,took,timeout
  17. 斐波那契数列python循环算法求解_斐波那契数列的算法实现 —— python
  18. 新药开发相关计算机辅助设计,研究称:药物开发将步入计算机辅助设计时代
  19. Rust 不同方式创建Arc对象性能对比
  20. web————http(报文详解篇)

热门文章

  1. python中classes和class的区别-Python中的Classes和Metaclasses详解
  2. 2020移动apn接入点哪个快_为什么都是4G网你的就没别人快?跟我这样设置,网速直线提升...
  3. html点击按钮删除session,删除sessionstorage
  4. php 链接多个mysql_PHP同时操作多个MySQL连接
  5. 第 5 章 Nova - 025 - OpenStack 通用设计思路
  6. Jupyter Notebook 基本使用
  7. UITableView学习笔记
  8. 浅谈 nagios监控配置
  9. Cocos2d之Action类详解
  10. 如何彻底禁用VS 2008的智能感知功能