当前位置:网站首页>FTP、ssh远程访问及控制
FTP、ssh远程访问及控制
2022-04-23 18:57:00 【朱暄的博客】
FTP
什么是FTP
FTP (File TransferProtocol,文件传输协议)是典型的c/s架构的应用层协议,需要由服务端软件、客户端软件两个部分共同实现文件传输功能。FTP客户端和服务器之间的连接是可靠的,面向连接的,为数据的传输提供了可靠的保证。tcp协议: 20
21端口:用于传输指令
20端口:用于传输数据
IFTP是一种文件传输协议,它支持两种模式,一种方式叫做Standard (也就是Active,主动方式),一种是Passive(也就是PASV,被动方式)。Standard模式FTP的客户端发送PORT命令到FTP server。 Passive模式FTP的客户端发送PASVO令到FTP Server
Standard模式
FTP客户端首先和FTP Server的TCP
21端口建立连接,通过这个通道发送命令,客户端需要接收数据的时候在这个通道上发送PORT命令。PORT命令包含了客户端用什么端口接收数据。在传送数据的时候,服务器端通过自己的TCP 20端口发送数据。FTPserver必须和客户端建立一个新的连接用来传送数据。
主动模式:
1)FTP连接请求(用户、密码连接模式命令端口等)
2)FTP服务器响应(ACK),服务器21号端口和客户端(高位端口)FTP会话连接
3)FTP服务器从自己的20号端口连接客户端发送连接请求是主动模式命令提供端口(高位)
4)最后客户端发送ACK确认,开始数据进行传输
Passive模式
在建立控制通道的时候和Standard模式类似,当客户端通过这个通道发送PASV命令的时候,FTP
server打开一个位于1024和5000之间的随机端口并且通知客户端在这个端口上传送数据的请求,然后FTP server将通过这个端口进行数据的传送,这个时候FTP server不再需要建立一个新的和客户端之间的连接。
被动模式:
1)FTP连接请求(用户、密码连接模式命令端口等)
2)FTP服务器响应(ACK)服务器21号端口和客户端(高位)建立FTP会话连接,但是这个响应过程会告诉客户端,服务器开放一个高位端口等你来连接
3)客户端给自己中的一个高位端口连接服务器响应高位端口
4)服务器给客户端一个ACK的响应,接下来就是数据传输过程
FTP作用与工作原理
FTP作用
作用: Internet上用来传送文件的协议。
VSFTP全称 (very secure FTP)
VSFTP模式: c/s模式
FTP服务器默认使用TCP协议的20、21端口与客户端进行通信
20端口用于建立数据连接,并传输文件数据
21端口用于建立控制连接,并传输FTP控制命令
FTP工作原理与流程
FTP数据连接分为两种模式:
主动模式和被动模式
FTP 会话包含了两个通道,控制通道和数据传输通道, FTP的工作有两种模式,一种是主动模式,一种是被动模式,以FTP Server为参照,主动模式,服务器主动连接客户端传输:被动模式,等待客户的连接
主动模式:服务器主动发起数据连接
被动模式:服务器被动等待数据连接
实验:搭建和配置FTP服务
查看是否安装软件包vsftp,没有安装进行yum安装
开启FTP服务
切换服务配置目录,并且备份
修改配置文件进入vim /etc/vsftpd/vsftpd.conf
修改后.(在下一行自己写入数据)
给FTP的根目录下的pub子目录最大权限
重启服务
检测
设置用户模式登录
将allow_writeable_chroot=YES允许被限制的用户主目录具有写的权限
重启服务
创建个用户让其登录
!
黑白名单
userlist_list默认位yes,为黑名单禁用
名单里由zhux所有不可登录了
SSH远程管理
openSSH服务器
SSH (Secure Shell)协议
是一种安全通道协议
对通信数据进行了加密处理,用于远程管理
OpenSSH
服务名称: sshd
服务端主程序: /usr/sbin/sshd
服务端配置文件: /etc/ssh/sshd_config
服务监听选项
端口号、协议版本、监听IP地址
禁用反向解析
[[email protected] -]# vi /etc/ssh/sshd_config
Port 22
ListenAddress 172.16.16.22
Protocol 2
UseDNS no
更改Port 22 为Port 2020 ,常规登录将不可登录 ,需要-p 2020
用户登录控制
禁用root用户、空密码用户
限制登录验证时间、重试次数
AllowUsers, DenyUsers
[[email protected] -]# vi /etc/ssh/sshd_config
LoginGraceTime 2m
PermitRootLogin no
MaxAuthTries 6
PermitEmptyPasswords no
AllowUsers jerry [email protected] AllowUsers不要与DenyUsers同时用
登录验证方式
密码验证:核对用户名、密码是否匹配
密钥对验证:核对客户的私钥、服务端公钥是否匹配
[[email protected] -]# vi /etc/ssh/sshd_config
PasswordAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys 启用密码验证、密钥对验证、指定公钥库位置
密码验证:
SSH客户端程序
ssh命令——远程安全登录
端口选项:-p 22
命令——远程安全复制
格式1: scp [email protected]:file1 file2
格式2: scp file1 [email protected]:file2
sftp命令——安全FTP上下载
sftp [email protected]
xshell
windows下一款功能非常强大的SSH客户端软件
构建密钥对验证的SSH体系:
在客机创造密钥对 ,上传公钥文件 ,将其导入到服务端用户lisi的公钥数据库 , 最后使用服务端的用户身份进行登录验证。
一创造密钥对
二将公钥文件给予对方用户
进入vim /etc/ssh/sshd_config
修改原本yes改成no wq报错并推出
systemctl restart sshd 重启服务
注意:两边机器都需更改此配置
3登录
版权声明
本文为[朱暄的博客]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_15531598/5248721
边栏推荐
- Getting started with vcpkg
- How about CICC wealth? Is it safe to open an account up there
- SQL中函数 decode()与 replace()的用法
- On iptables
- How can programmers quickly develop high-quality code?
- MySQL学习第五弹——事务及其操作特性详解
- 教你用简单几个步骤快速重命名文件夹名
- Nacos cluster construction and MySQL persistence configuration
- Deeply understand what new and make in golang are and what are the differences?
- Practice of Druid SQL and security in meituan review
猜你喜欢
2022.04.23 (the best time for lc_714_to buy and sell stocks, including handling charges)
listener. log
After opening the original normal project, the dependency package displays red and does not exist.
微搭低代码零基础入门课(第三课)
视频边框背景如何虚化,简单操作几步实现
【科普】CRC校验(一)什么是CRC校验?
iptables -L执行缓慢
Using Visual Studio code to develop Arduino
[today in history] April 23: the first video uploaded on YouTube; Netease cloud music officially launched; The inventor of digital audio player was born
ctfshow-web361(SSTI)
随机推荐
Introduction to micro build low code zero Foundation (lesson 3)
An 8266 crash
Redis common interview questions
Coolweather is revised and connected to the wind weather interface to realize the broken line diagram of temperature
回路-通路
Dynamically add and delete layouts
STM32: LCD display
Go 语言 GUI 框架 fyne 中文乱码或者不显示的问题
From technical system to business insight, the closing chapter of the practice of small and medium-sized R & D team structure
MVVM模型
MySQL statement
Simplified path (force buckle 71)
Methods of nested recycleview to solve sliding conflict and incomplete item display
ESP32 LVGL8. 1 - arc (arc 19)
ctfshow-web362(SSTI)
Esp32 (UART 485 communication) - 485 communication of serial port (3)
Loop path
Database computer experiment 4 (data integrity and stored procedure)
Golang 语言实现TCP UDP通信
How to virtualize the video frame and background is realized in a few simple steps