RHCE第一次作业

1.准备两台服务器,配置服务器1免密登录到服务器2, 配置服务器2免密登录到服务器1

开启两台虚拟机 192.168.134.130 192.168.134.133

先在1号虚拟机上生成秘钥
 

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? 
[root@localhost ~]# 
[root@localhost ~]# cd /root/.ssh
root@localhost .ssh]# ls -l
total 8
-rw-------. 1 root root 2610 Sep 17 11:52 id_rsa
-rw-r--r--. 1 root root  574 Sep 17 11:52 id_rsa.pub

再将客户端的id_rsa.pub拷贝到服务器端
 

[root@localhost .ssh]# scp /root/.ssh/id_rsa.pub  192.168.134.132:/root/.ssh/
The authenticity of host '192.168.134.132 (192.168.134.132)' can't be established.
ED25519 key fingerprint is SHA256:gcYkW16BMFM1RGml5XQolVkuh2imPlRZqz6nZW2Xamk.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Warning: Permanently added '192.168.134.132' (ED25519) to the list of known hosts.
root@192.168.134.132's password: 
id_rsa.pub                                                               100%  574   575.3KB/s   00:00    

再在服务器端进行操作,将公钥文件重定向到认证文件当中
 

[root@localhost ~]# cd /root/.ssh
[root@localhost .ssh]# cat id_rsa.pub >> authorized_keys~

测试从客户端免密登录
 

[root@localhost ~]# ssh root@192.168.134.133
Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Fri Sep 22 09:48:30 2023 from 192.168.134.1

由此可得免密登陆成功
再设置服务端到客户端的免密登录
 

[root@localhost ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? 
[root@localhost ~]# scp /root/.ssh/id_rsa.pub  192.168.134.130:/root/.ssh/
The authenticity of host '192.168.134.130 (192.168.134.130)' can't be established.
ED25519 key fingerprint is SHA256:gcYkW16BMFM1RGml5XQolVkuh2imPlRZqz6nZW2Xamk.
This host key is known by the following other names/addresses:
    ~/.ssh/known_hosts:1: 192.168.134.132
    ~/.ssh/known_hosts:4: 192.168.134.133
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.134.130' (ED25519) to the list of known hosts.
id_rsa.pub                                                                                                                          100%  580     2.2MB/s   00:00    
[root@localhost ~]# ssh root@192.168.134.130
Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Fri Sep 22 10:12:15 2023 from 192.168.134.133
[root@localhost ~]# 

由此可得双机免密登录设置成功

 2.ssh工作流程分为哪几个阶段 

SSH(Secure Shell)的工作流程可以分为以下几个阶段:

  1. 连接建立:SSH客户端向SSH服务器发起连接请求,并进行身份验证过程。通常使用用户名和密码进行身份验证,也可以使用公钥认证。

  2. 加密通信:一旦身份验证成功,SSH双方之间建立起安全的加密通道。这个通道将用于后续的数据传输,确保数据在传输过程中的机密性和完整性。

  3. 会话管理:一旦加密通信建立,SSH客户端和服务器之间可以进行会话管理。这意味着客户端可以在服务器上执行命令或运行远程应用程序,而且所有传输的数据都经过加密保护。

  4. 数据传输:在会话管理期间,SSH客户端和服务器之间可以交换数据。这包括远程执行命令时的输入和输出数据,以及远程文件传输。

  5. 连接终止:当会话完成或用户主动断开连接时,SSH客户端和服务器之间的连接将被终止。在终止连接之前,会话管理和加密通道也将被关闭。

总的来说,SSH工作流程涉及连接建立、身份验证、加密通信、会话管理和连接终止等多个阶段,这些阶段共同确保了安全而可靠的远程访问和数据传输。

 3.ssh工作流程中使用到哪几类加密算法,以及对称加密常用的算法有哪些,非对称加密算法有哪些

SSH(Secure Shell)是一种用于远程登录和安全数据传输的协议,它在工作流程中使用多种加密算法来确保通信的机密性和完整性。以下是SSH工作流程中使用的主要加密算法类别以及其中常用的算法:

(1) 对称加密算法(Symmetric Encryption Algorithms):
   对称加密算法在SSH中用于加密通信的数据。它使用相同的密钥来进行加密和解密。

   常用的对称加密算法包括:
   - AES(Advanced Encryption Standard):AES是目前广泛使用的对称加密算法之一,支持多种密钥长度(如AES-128、AES-192和AES-256)。
   - 3DES(Triple Data Encryption Standard):3DES是一种对称加密算法,使用三次DES加密操作以增强安全性。但它相对较慢,因此不太常用。

(2)非对称加密算法(Asymmetric Encryption Algorithms):
   非对称加密算法用于SSH中的密钥交换和身份验证。它涉及一对密钥:公钥和私钥。公钥用于加密数据,私钥用于解密。

   常用的非对称加密算法包括:
   - RSA(Rivest-Shamir-Adleman):RSA是最常见的非对称加密算法之一,用于密钥交换和数字签名。
   - DSA(Digital Signature Algorithm):DSA用于数字签名,通常与Diffie-Hellman密钥交换结合使用。
   - ECDSA(Elliptic Curve Digital Signature Algorithm):ECDSA是一种基于椭圆曲线的非对称加密算法,也用于数字签名。

(3)散列函数(Hash Functions):
   SSH还使用散列函数来确保数据的完整性,通常用于生成消息认证码(MAC)。

   常用的散列函数包括:
   - SHA-1(Secure Hash Algorithm 1):虽然以前广泛使用,但由于安全性问题,现在不再建议使用。
   - SHA-256、SHA-384、SHA-512:这些SHA-2系列的散列函数是当前推荐的选择。

在SSH工作流程中,这些加密算法共同用于建立安全的通信通道,以保护数据免受窃听和篡改。通常,SSH客户端和服务器之间会根据协商的支持算法来选择最佳的加密方式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值