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

RHCE 第二次作业

配置ssh实现A,B主机互相免密登录

客户端

1.制作公私钥对

[root@shutiao ~]# 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:qN0Q70WZKeyxtCAd4zZIaNSfyJfcftvImlppMbmRza4 root@shutiao
The key's randomart image is:
+---[RSA 3072]----+
| ..o. o          |
|  o..+ +   +     |
| . .o+B+= =      |
|    oo*O.@       |
|     .o.S +      |
|     o +.O.      |
|    . . Bo.+     |
|       o o+ .    |
|      ..E.       |
+----[SHA256]-----+


2.将公钥上传到服务器端

ssh-copy-id root@192.168.153.166
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.153.166 (192.168.153.166)' can't be established.
ED25519 key fingerprint is SHA256:nUpp98jf5J/XswFlnvBfGMusDQ23L0R7Jf0GcQkgxBc.
This host key is known by the following other names/addresses:~/.ssh/known_hosts:1: www.shutiao.com~/.ssh/known_hosts:4: hehe.com
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.153.166's password:Number of key(s) added: 1Now try logging into the machine, with:   "ssh 'root@192.168.153.166'"
and check to make sure that only the key(s) you wanted were added.[root@shutiao ~]# ssh root@192.168.153.166
Activate the web console with: systemctl enable --now cockpit.socketRegister this system with Red Hat Insights: rhc connectExample:
# rhc connect --activation-key <key> --organization <org>The rhc client and Red Hat Insights will enable analytics and additional
management capabilities on your system.
View your connected systems at https://console.redhat.com/insightsYou can learn more about how to register your system
using rhc at https://red.ht/registration


3.客户端测试
 

[root@shutiao ~]# ssh root@192.168.153.131[root@server1 ~]#

服务端

1.制作公私钥对

[root@server1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): ^[[A
Enter passphrase (empty for no passphrase):
Enter same passphrase again:      .pub
The key fingerprint is:n saved in  in
SHA256:XX78x2u8mQXICKTrU6HPC/J1tQJyzddOO/5e8wd4awo root@server1
The key's randomart image is:
+---[RSA 3072]----+
|        .        |
|       o         |
|      . o   .    |
|       o * = +   |
|      + S = *.*  |
|     . * . o.=o= |
|    . + + E ..=+*|
|     o + o o .o+@|
|      . .   .ooB*|
+----[SHA256]-----+

2.将公钥上传到服务器端


[root@server1 ~]# ssh-copy-id  root@192.168.153.131

3.服务端测试

[root@server1 ~]# ssh root@192.168.153.131
Activate the web console with: systemctl enable --now cockpit.socketRegister this system with Red Hat Insights: rhc connectExample:
# rhc connect --activation-key <key> --organization <org>The rhc client and Red Hat Insights will enable analytics and additional
management capabilities on your system.
View your connected systems at https://console.redhat.com/insightsYou can learn more about how to register your system
using rhc at https://red.ht/registration
Last login: Mon May  5 14:16:24 2025 from 192.168.153.1
[root@shutiao ~]#

配置nginx服务,通过多ip区分多网站

1.准备工作

[root@server2 ~]# systemctl stop firewalld
[root@server2 ~]# setenforce 0
[root@server2 ~]# yum install nginx

2.配置不同IP

[root@server2 ~]# nmtui

 

3.配置文件

[root@server2 ~]# vim /etc/nginx/conf.d/ip.conf server{listen 192.168.153.134;root /www/ip/134;}
server{listen 192.168.153.196;root /www/ip/196;}
[root@server2 ~]# mkdir /www/ip/{134,196} -pv
mkdir: created directory '/www/ip'
mkdir: created directory '/www/ip/134'
mkdir: created directory '/www/ip/196'
[root@server2 ~]# echo this is 134 > /www/ip/134/index.html
[root@server2 ~]# echo this is 196 > /www/ip/196/index.html
[root@server2 ~]# systemctl restart nginx 

 4.测试

[root@server2 ~]# curl 192.168.153.134
this is 134
[root@server2 ~]# curl 192.168.153.196
this is 196

http://www.xdnf.cn/news/4007.html

相关文章:

  • LeetCode 热题 100 118. 杨辉三角
  • boke luntan shop edu自动化脚本
  • 民宿管理系统5
  • WidowX-250s 机械臂的简单数字孪生案例
  • 【NLP】 31. Retrieval-Augmented Generation(RAG):KNN-LM, RAG、REALM、RETRO、FLARE
  • 【渗透测试】Web服务程序解析漏洞原理、利用方式、防范措施
  • C++进阶之——多态
  • 【C++项目实战】日志系统
  • WEB表单和表格标签综合案例
  • win10启动项管理在哪里设置?开机启动项怎么设置
  • Android工厂模式
  • 抽奖系统(基于Tkinter)
  • 微服务项目中网关服务挂了程序还可以正常运行吗
  • 数学复习笔记 2
  • JAVA在线考试系统考试管理题库管理成绩查询重复考试学生管理教师管理源码
  • JobHistory Server的配置和启动
  • LCD,LED
  • 期末项目Python
  • GoogleTest:GMock初识
  • 嵌入式开发学习日志Day13
  • window 系统 使用ollama + docker + deepseek R1+ Dify 搭建本地个人助手
  • C++笔记之接口`Interface`
  • 恶心的win11更新DIY 设置win11更新为100年
  • 《赤色世界》彩蛋
  • 数据封装的过程
  • 分析atoi(),atol()和atof()三个函数的功能
  • 【今日三题】小红的口罩(小堆) / 春游(模拟) / 数位染色(01背包)
  • 【Bootstrap V4系列】学习入门教程之 组件-卡片(Card)
  • Linux怎么更新已安装的软件
  • sudo useradd -r -s /bin/false -U -m -d /usr/share/ollama ollama解释这行代码的含义