午
在物理及和虚拟主机上配置ftp,实现上传和下载的功能
1.在虚拟机中安装vsftpd软件
[root@q1 ~]# yum -y install vsftpd
2.查看配置文件目录 /etc/vsftpd
[root@q1 ~]# cd /etc/vsftpd/[root@q1 vsftpd]# lsftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
3.开启ftp服务,并关闭防火墙和selinux
[root@q1 vsftpd]# systemctl start vsftpd[root@q1 vsftpd]# systemctl stop firewalld [root@q1 vsftpd]# setenforce 0
4.进入共享目录 /var/ftp创建测试文件
[root@q1 vsftpd]# ls /var/ftppub[root@q1 vsftpd]# echo "this is test" > /var/ftp/test.txt
5.创建测试用户,并设置密码
[root@q1 vsftpd]# useradd uftp [root@q1 vsftpd]# echo 1 | passwd --stdin uftp 更改用户 uftp 的密码 。passwd:所有的身份验证令牌已经成功更新。
6.进入物理机cmd命令框,使用ftp连接虚拟机
C:\Users\31836>ftp 192.168.1.21连接到 192.168.1.21。220 (vsFTPd 3.0.2)200 Always in UTF8 mode.用户(192.168.1.21:(none)): uftp331 Please specify the password.密码:
230 Login successful.ftp> ls200 PORT command successful. Consider using PASV.150 Here comes the directory listing.226 Directory send OK.
7.进入共享目录,查看测试文件
ftp> cd /var/ftp250 Directory successfully changed.ftp> ls200 PORT command successful. Consider using PASV.150 Here comes the directory listing.pubtest.txt226 Directory send OK.ftp: 收到 18 字节,用时 0.00秒 18000.00千字节/秒。
下载/上传test.txt文件
ftp> get test.txt200 PORT command successful. Consider using PASV.150 Opening BINARY mode data connection for test.txt (13 bytes).226 Transfer complete.ftp: 收到 13 字节,用时 0.00秒 13000.00千字节/秒。
上传
ftp> put test.txt200 PORT command successful. Consider using PASV.150 Ok to send data.226 Transfer complete.ftp: 发送 13 字节,用时 0.00秒 13000.00千字节/秒