当前位置: 首页 > news >正文

rhce第二次作业

任务目标

1.配置ssh实现A,B主机互相免密登录
2.配置nginx服务,通过多ip区分多网站

任务一

关闭防火墙

[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld.service 

A主机免密登录B主机

### A主机生成密钥
[root@localhost ~]# ssh-keygen -t RSA    #-t RSA 非对称算法
Generating public/private RSA key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):   #enter 默认存储目录
Enter passphrase (empty for no passphrase):    #enter 默认无密码
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:8a0Kzu/gbqNGzaEadlreu8v0CHb2fkHvQpfs/iw7liI root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|                 |
|                 |
|        .        |
|      .  o..     |
|     + .S..o..   |
|  o = o   o.=    |
| . Oo.*  ..= .   |
|  o.oX+*E.+ B.   |
|   ..+@OBo =o=o  |
+----[SHA256]-----+###检查生成的密钥是否在默认路径
[root@localhost ~]# ll /root/.ssh
总用量 8
-rw-------. 1 root root 2655  5月  3 09:49 id_rsa
-rw-r--r--. 1 root root  580  5月  3 09:49 id_rsa.pub###将A主机公钥拷贝到B主机
[root@localhost ~]# ssh-copy-id root@192.168.17.129
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.17.129 (192.168.17.129)' can't be established.
ED25519 key fingerprint is SHA256:BwZ4cqQb3WYw/nzjMXT+j6BP5FnIbow9zFeIjEDEKp8.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.17.129's password: Number of key(s) added: 1Now try logging into the machine, with:   "ssh 'root@192.168.17.129'"
and check to make sure that only the key(s) you wanted were added.###A免密连接B测试
[root@localhost ~]# ssh 192.168.17.129
Activate the web console with: systemctl enable --now cockpit.socketRegister 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: Sat May  3 09:57:36 2025 from 192.168.17.1

B主机免密登录A主机同理

###B主机生成密钥
[root@localhost ~]# ssh-keygen -t RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa
Your public key has been saved in /root/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:/Pb6m9qrq8PwZKTnFt14CK0hGuW2uJ95vT4VxK9OBWA root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|          Eo     |
|      .  .  +    |
|     o   . . o   |
|    . +.+ . . o  |
|     = =S= + +   |
|    o + *.+ *    |
|     . O oo=     |
|    .  oB.oo..   |
|     .+o.+BOBo   |
+----[SHA256]-----+###拷贝密钥到A主机
[root@localhost ~]# ssh-copy-id 192.168.17.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.17.128's password: Number of key(s) added: 1Now try logging into the machine, with:   "ssh '192.168.17.128'"
and check to make sure that only the key(s) you wanted were added.###B主机连接A主机测试
[root@localhost ~]# ssh 192.168.17.128
Activate the web console with: systemctl enable --now cockpit.socketRegister 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: Sat May  3 09:43:54 2025 from 192.168.17.1

任务二

配置多个网卡

打开虚拟机设置,点击下方的添加

 选择安装网络适配器,确定后回到虚拟机

 

输入ifconfig指令查看新添加的网卡

###激活ens224网卡
[mohe@localhost ~]$ nmcli device connect ens224
设备 "ens224" 成功以 "f2130624-5326-4d3f-9908-16d9f7c1ef6a" 激活。
[mohe@localhost ~]$ nmcli connection up ens224
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/6)

安装以及使用nginx

配置多ip多网站信息

[root@localhost mohe]# dnf install nginx
[root@localhost ~]# vim /etc/nginx/conf.d/ip.conf

 vim界面

###创建目录,添加文件
[root@localhost ~]# mkdir /www/ip/{128,130} -pv
mkdir: 已创建目录 '/www'
mkdir: 已创建目录 '/www/ip'
mkdir: 已创建目录 '/www/ip/128'
mkdir: 已创建目录 '/www/ip/130'
[root@localhost ~]# echo this is 128 > /www/ip/128/index.html
[root@localhost ~]# echo this is 130 > /www/ip/130/index.html
[root@localhost ~]# systemctl restart nginx

 结果如下

相关文章:

  • Elasticsearch 中的索引模板:如何使用可组合模板
  • 快速搭建并学会使用Mybatis!!
  • Linux中进程的属性:进程优先级
  • Pytorch-CUDA版本环境配置
  • The Traitor King (10 player 25 player)
  • 哈希函数详解(SHA-2系列、SHA-3系列、SM3国密)案例:构建简单的区块链——密码学基础
  • 游戏引擎学习第256天:XBox 控制器卡顿和修复 GL Blit 伽玛问题
  • 数据分析与可视化实战:从鸢尾花到乳腺癌数据集
  • AI日报 · 2025年5月03日|Perplexity 集成 WhatsApp,苹果传与 Anthropic 合作开发 Xcode
  • list类的详细讲解
  • day13 python不平衡数据集的处理(补)
  • 类与类之间的关系详解
  • InnoDB索引的原理
  • 实验二 软件白盒测试
  • 状压 DP 详解
  • 一种快速计算OTA PSRR的方法(Ⅰ)
  • 前端面经-VUE3篇--vue3基础知识(二)计算属性(computed)、监听属性(Watch)
  • 双指针(5)——有效三角形个数
  • 头皮理疗预约小程序开发实战指南
  • 大模型开发学习笔记
  • 潘功胜发布会答问五大要点:除了降准降息,这些政策“含金量”也很高
  • 青岛鞋企双星名人集团家族内斗:创始人发公开信指控子孙夺权
  • 科技赋能文化体验,“五一”假期“海昏侯”人气创新高
  • 保持高位运行,今天全国铁路预计发送旅客1800万人次
  • 胖东来回应“浙江‘胖都来’卖场开业”:已取证并邮寄律师函
  • 全国台联原会长杨国庆逝世,享年89岁