Linux实验二(1)vsftpd的安装和访问(课程笔记)

1、安装:

yum install vsftpd

2、查看是否安装成功:

root@localhost: ~21#  rpm -q vsftpd
vsftpd-3.0.3-31.el8.x86_64

或者:

root@localhost: ~22# yum list installed | grep vsftpd
vsftpd.x86_64                                    3.0.3-31.el8 

查看软件安装列表:

root@localhost: ~29# rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/lib/.build-id
/usr/lib/.build-id/a7
...

3、启动服务

root@localhost: ~3# service vsftpd start
root@localhost: ~2# netstat -nltp| grep vsftpd
tcp6       0      0 :::21                   :::*                    LISTEN      954/vsftpd          


4、测试验证(匿名用户)
在windows下匿名用户访问:

  1. 在主机win10中ping服务器:
C:\Users\HP>ping 192.168.68.139

正在 Ping 192.168.68.139 具有 32 字节的数据:
来自 192.168.68.139 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.68.139 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.68.139 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.68.139 的回复: 字节=32 时间<1ms TTL=64

192.168.68.139 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms
    
  1. 用浏览器访问:
    在浏览器输入ftp://192.168.68.139/
    在这里插入图片描述访问成功

或者在资源管理器中输入ftp://192.168.68.139/
在这里插入图片描述
在Linux下访问:
两个工具:ftp和lftp(客户端工具)
首先确保Linux客户端能够访问服务器:

[kanber@localhost ~]$ ping 192.168.68.139
PING 192.168.68.139 (192.168.68.139) 56(84) bytes of data.
64 bytes from 192.168.68.139: icmp_seq=1 ttl=64 time=0.382 ms
64 bytes from 192.168.68.139: icmp_seq=2 ttl=64 time=0.354 ms
64 bytes from 192.168.68.139: icmp_seq=3 ttl=64 time=0.401 ms
64 bytes from 192.168.68.139: icmp_seq=4 ttl=64 time=0.504 ms
64 bytes from 192.168.68.139: icmp_seq=5 ttl=64 time=0.348 ms

然后安装ftp和lftp

[root@localhost ~]# yum install ftp lftp

匿名登陆:
1、使用ftp

[root@localhost ~]# ftp 192.168.68.139
Connected to 192.168.68.139 (192.168.68.139).
220 (vsFTPd 3.0.3)
Name (192.168.68.139:root): ftp   //匿名登录用户使用ftp
331 Please specify the password.
Password:                         //匿名用户默认没有密码,直接按回车
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,68,139,209,17).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Jun 18 08:40 file1
-rw-r--r--    1 0        0               0 Jun 18 08:40 file2
-rw-r--r--    1 0        0               0 Jun 18 08:40 file3
drwxr-xr-x    2 0        0               6 Apr 24 03:01 pub
226 Directory send OK.

2、使用lftp

[root@localhost ~]# lftp 192.168.68.139
lftp 192.168.68.139:~> ls            //默认为匿名登陆,不需要输入密码
-rw-r--r--    1 0        0               0 Jun 18 08:40 file1
-rw-r--r--    1 0        0               0 Jun 18 08:40 file2
-rw-r--r--    1 0        0               0 Jun 18 08:40 file3
drwxr-xr-x    2 0        0               6 Apr 24 03:01 pub

5、本地用户访问
1、在服务器上添加本地用户

root@localhost: ~23# useradd code1
root@localhost: ~24# echo 123|passwd --stdin code1
更改用户 code1 的密码 。
passwd:所有的身份验证令牌已经成功更新。
root@localhost: ~26# su - code1
[code1@localhost ~]$ touch ab
[code1@localhost ~]$ ll
总用量 0
-rw-rw-r--. 1 code1 code1 0 6月  18 05:17 ab

2、在资源管理器中登录
在这里插入图片描述
在这里插入图片描述
3、在Linux客户端登陆:
使用ftp

[root@localhost ~]# ftp 192.168.68.139
Connected to 192.168.68.139 (192.168.68.139).
220 (vsFTPd 3.0.3)
Name (192.168.68.139:root): code1
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (192,168,68,139,186,169).
150 Here comes the directory listing.
-rw-rw-r--    1 1001     1001            0 Jun 18 09:17 ab
drwxrwxr-x    3 1001     1001           26 Jun 18 09:23 file1
226 Directory send OK.
ftp> pwd
257 "/home/code1" is the current directory //默认目录为/home/code1

使用lftp:

[root@localhost ~]# lftp 192.168.68.139
lftp 192.168.68.139:~> user code1 //输入user+"用户名"
Password: 
lftp code1@192.168.68.139:~> 

上传和下载文件:

lftp code1@192.168.68.139:~> put test1  //使用put上传文件
471 bytes transferred                    
lftp code1@192.168.68.139:~> 
lftp code1@192.168.68.139:~> ls
-rw-rw-r--    1 1001     1001            0 Jun 18 09:17 ab
drwxrwxr-x    3 1001     1001           26 Jun 18 09:23 file1
-rw-r--r--    1 1001     1001          471 Jun 18 09:34 test1
lftp code1@192.168.68.139:~> get ab   //使用get下载文件
lftp code1@192.168.68.139:~> exit
[root@localhost ~]# ll
total 12
-rw-r--r--. 1 root root    0 Jun 18 17:17 ab
-rw-------. 1 root root 1908 May  7 08:43 anaconda-ks.cfg
-rw-r--r--. 1 root root 1939 May  7 09:06 initial-setup-ks.cfg
-rw-r--r--. 1 root root  471 Jun 19 01:30 test1

总结:默认情况下,允许匿名用户下载文件,不允许上传文件。允许本地用户下载和上传文件。

搭建服务的思路:
1、关闭防火墙和selinux(或者设置防火墙允许服务运行)
2、配置yum源
3、软件三部曲:

  • 安装软件
  • 确定软件安装成功
  • 查看软件的文件列表(启动脚本/配置文件/命令/man/doc)

4、根据需求修改配置文件来完成服务的搭建(man 5 xxx.conf)
5、启动服务,开机自启动(ss/netstat/lsof -i:port)
6、测试验证

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值