当前位置:网站首页>ssh服务详解
ssh服务详解
2022-08-04 01:44:00 【小猴子_xiao】
理解ssh服务的两种认证方式
掌握ssh服务的基本配置
掌握ssh服务客户端工具的使用
一、SSH介绍
SSH是Linux下远程管理的工具,相比Telnet安全,运维人员必备的神器!
SSH的全称Secure Shell,安全的shell,是Client/Server架构,默认端口号为22,TCP/IP协议
SSH有v1和v2版本
ssh v1:有漏洞,容易受到攻击
ssh v2:通过公钥加密(数字签名和密钥交换)的方式进行,确保服务器端的身份识别
二、SSH加密算法
des 对称的公钥加密算法,安全低,数据传输速度快;使用同一个秘钥进行加密或解密
rsa 非对称的公钥加密算法,安全,数据传输速度慢 ,SSH默认的加密算法
补充了解:
DSA数字签名,非对称加密的另一种实现。
DSA-Digital Signature Algorithm 是Schnorr和ElGamal签名算法的变种。简单的说,这是一种更高级的验证方式,用作数字签名。不单单只有公钥、私钥,还有数字签名。私钥加密生成数字签名,公钥验证数据及签名。如果数据和签名不匹配则认为验证失败!数字签名的作用就是校验数据在传输过程中不被修改。

三、SSH服务的认证方式
基于用户密码的认证
[[email protected] ~]# ssh 192.168.10.171
The authenticity of host '192.168.10.171 (192.168.10.171)' can't be established.
RSA key fingerprint is 9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95.
Are you sure you want to continue connecting (yes/no)?
提示信息:无法确认主机192.168.10.171的真实性,指纹是9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95.,你确定想要继续吗?
说明: 理论上应该是对公钥的确认,由于公钥通过RSA算法加密,太长,不好直接比较,所以给公钥生成一个hash的指纹,方便比较。
[email protected] ~]# ssh 192.168.10.171
The authenticity of host '192.168.10.171 (192.168.10.171)' can't be established.
RSA key fingerprint is 9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95.
Are you sure you want to continue connecting (yes/no)? yes说明:
当客户端输入yes确认对方的公钥指纹后,server端的公钥就会被存放到客户机的用户家目录里~/.ssh/known_hosts文件中,下次再访问就直接通过密码登录,不需要再确认公钥。
[[email protected] ~]# su - stu1
[[email protected] ~]$ ssh 10.1.1.2
The authenticity of host '10.1.1.2 (10.1.1.2)' can't be established.
RSA key fingerprint is 9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.1.2' (RSA) to the list of known hosts.
[email protected]'s password: 四、SSH服务基本配置
部署环境:需要2台云服务器,这里我用的是3A网络的,非常适合小白,容器操作,可以随时更换ip地址。
基于秘钥对认证(免密码登录)——>重点掌握
需求:client端有一个用户user01,该用户使用root用户免密码登录server端
环境:
client:10.1.1.3
server:10.1.1.2
思路:
client端生成一对秘钥
将生成的公钥远程拷贝到server端
步骤:
client端的user01用户生成一对秘钥对
[[email protected] ~]# useradd user01 [[email protected] ~]# su - user01 [[email protected] ~]$ ls -a . .. .bash_logout .bash_profile .bashrc .emacs .gnome2 .mozilla [[email protected] ~]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/user01/.ssh/id_rsa): Created directory '/home/user01/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user01/.ssh/id_rsa.将刚刚生成的公钥远程拷贝到server端的root家目录里指定位置
[[email protected] ~]$ scp .ssh/id_rsa.pub [email protected]:/root/.ssh/authorized_keys 或者 [[email protected] ~]$ ssh-copy-id -i .ssh/id_rsa.pub [email protected] (推荐) The authenticity of host '10.1.1.2 (10.1.1.2)' can't be established. RSA key fingerprint is 9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.1.1.2' (RSA) to the list of known hosts. [email protected]'s password:测试验证
[[email protected] ~]$ ssh [email protected] Last login: Mon Apr 16 16:00:55 2018 from 10.1.1.1 [[email protected] ~]#
边栏推荐
- 22/8/3(板子)树状dp板子+中国剩余定理+求组合数3,4+容斥原理
- SAP SD module foreground operation
- Flask Framework Beginner-05-Command Management Manager and Database Use
- 安全至上:落地DevSecOps最佳实践你不得不知道的工具
- Priority_queue element as a pointer, the overloaded operators
- Kubernetes:(九)coredns(浪不动了)
- 【无标题】
- Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
- 实例035:设置输出颜色
- 5.scrapy中间件&分布式爬虫
猜你喜欢

The idea of the diagram

Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment

pygame 中的transform模块

2022年上半年各大厂Android面试题整理及答案解析(持续更新中......)

Flink jdbc connector 源码改造sink之 clickhouse多节点轮询写与性能分析

Flask Framework Beginner-06-Add, Delete, Modify and Check the Database

Example: 036 is a prime number

Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment

循环绕过问题

GraphQL背后处理及执行过程是什么
随机推荐
nodejs install multi-version version switching
LDO investigation
IDEA02:配置SQL Server2019数据库
html select标签赋值数据库查询结果
多渠道打包
贪吃蛇游戏Bug解析及功能扩展
谁说程序员不懂浪漫,表白代码来啦~
nodejs 安装多版本 版本切换
多线程 之 JUC 学习篇章一 创建多线程的步骤
Simple sorting (summer vacation daily question 14)
nodejs+npm的安装与配置
Observability:你所需要知道的关于 Syslog 的一些知识
Security First: Tools You Need to Know to Implement DevSecOps Best Practices
(cf)Codeforces Round #811 (Div. 3)A--E详细题解
MySQL回表指的是什么
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
Engineering drawing review questions (with answers)
Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
Small Turtle Compilation Notes
2022 中国算力大会发布“创新先锋”优秀成果