Linux两台主机做ssh互信

news/2024/8/30 22:14:48 标签: ssh, linux, 互信
测试1号机 10.0.0.250
测试2号机 10.0.0.251 
 
备注:操作系统Centos7.4
测试1号机(10.0.250)
[root@cs-app1 ssh]# ssh-keygen    # 生成公钥
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)? y
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:xBVhKTIsNDZDaiucGVGWbJ56WrZvQI071eYJ6lIJvP0 root@cs-app1
The key's randomart image is:
+---[RSA 2048]----+
| .o=O.    =+     |
|  o*.++..o.      |
|..= +..oo.       |
|.++* + +         |
|.+B = + S        |
| + %   o         |
|  B =            |
| o o E           |
|  . o.           |
+----[SHA256]-----+
[root@cs-app1 ~]# cd .ssh
[root@cs-app1 .ssh]# ll
total 12
-rw------- 1 root root 1679 Sep  8 04:21 id_rsa
-rw-r--r-- 1 root root  394 Sep  8 04:21 id_rsa.pub
-rw-r--r-- 1 root root  344 Sep  8 04:15 known_hosts
[root@cs-app1 ~]# ssh-copy-id 10.0.0.251  # 上传公钥到 0.251
/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@10.0.0.251's password:
 
Number of key(s) added: 1
 
Now try logging into the machine, with:   "ssh '10.0.0.251'"
and check to make sure that only the key(s) you wanted were added.
 
[root@cs-app1 ~]# ssh 10.0.0.251
Last login: Tue Sep  8 04:22:16 2020 from 10.0.0.250
[root@cs-app2 ~]# exit
[root@cs-app1 .ssh]# ssh 10.0.0.251   # 验证
Last login: Tue Sep  8 04:26:02 2020 from 10.0.0.250
[root@cs-app2 ~]# hostname -I
10.0.0.251 192.168.122.1
 
测试2号机(10.0.0.251)
[root@cs-app2 ~]# ssh-keygen   # 生成公钥
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)? y
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:cOsOkQyFC+Cz1GPy8LMggieBlXVcAnCkOg3EYB3KW3Y root@cs-app2
The key's randomart image is:
+---[RSA 2048]----+
|=++**++..        |
|*o=+.o..         |
|+O.B.E. .        |
|o=% +o + .       |
|B+o+  + S        |
|o+. o  o         |
|   .  . .        |
|       o         |
|        .        |
+----[SHA256]-----+
 
[root@cs-app2 ~]# ssh-copy-id 10.0.0.250  # 拷贝公钥到 0.250
/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@10.0.0.250's password:
 
Number of key(s) added: 1
 
Now try logging into the machine, with:   "ssh '10.0.0.250'"
and check to make sure that only the key(s) you wanted were added.
 
[root@cs-app2 ~]# ssh 10.0.0.250
Last login: Tue Sep  8 04:25:06 2020 from 10.0.0.251
[root@cs-app1 ~]# exit
Logout
[root@cs-app2 .ssh]# ssh 10.0.0.250   # 测试登录 0.250
Last login: Tue Sep  8 04:25:53 2020 from 10.0.0.251
[root@cs-app1 ~]# hostname -I
10.0.0.250 192.168.122.1
 
WEIXIN:13383754368
备注:一起学习。

http://www.niftyadmin.cn/n/1252924.html

相关文章

OpenStack构建企业私有云Glance(3)

​OpenStack中的Glance是镜像服务,能够提供发现、注册并查询虚拟机镜像,也是Openstack的一个组件或者说项目之一。镜像服务提供了一个Rest API的方式。 OpenStack的Glance镜像可以存放在本地文件系统,也可以存放在OpenStack的对象存储上。…

CP IPS功能测试

测试环境:CP 15000硬件 测试拓扑: Step1:重新安装Check_Point_R80.10_T479_Gaia并且打补丁 Step2:初始化CP并且部署模式为Management和Gateway安装在一台设备上 Step3:配置桥接接口,如下图: 激活external接口 激活internal接口 创…

windows不能显示此连接属性。windows management instrumentation (WMI) 信息可能损坏

Windows Management Instrumentation (WMI)信息可能损坏错误修复 在 查看“本地连接”的属性,并切换到“高级”选项卡后,提示:“Windows不能显示此连接的属性。Windows Management Instrumentation(Windows管理体系结构组件WMI)信息可能损坏。要更正此问…

There' s a lot to learn. It's a new world.

要有思路,和心态。 https://segmentfault.com/a/1190000013329013

oracle 10g 手动创建scott(tiger) schema

转自:http://cnhtm.itpub.net/post/39970/496967 为了学习数据库,今天装上了Oracle 10g,装了以后发现没有scott账户,并不像别的文章里说的scott账户已锁定,而是完全没有,搜了很多才明白自己在安装的时候没有选择安装演…

一个JAVA程序员成长之路———没有尽头

来自https://blog.csdn.net/asunlei/article/details/79649183 的节选 首先 JAVA基础语法 集合类 线程 IO操作, 这些掌握了 基础算是过关了 其次 web部分 servlet jsp session cookie mysql数据库 都要知道怎么操作怎么用学到这个阶段,你需要知道一个请求从页面或者移动端发起之…

做一个关于小小小程序编码的总结

在完成一个简单的“登陆学生管理系统”后的总结: 忘记全局变量的定义,导致代码的一直报错。函数的调用出现了思维上的混乱。函数的编写代码出现了简单的逻辑和语法错误。抽象的理解,没有对此次编程做大面上的观察。逆向思维的运用&#xff0c…

阅读

我只是看起来很努力 https://blog.csdn.net/zcc1229936385/article/details/79713004 投资未来最好的自己 https://blog.csdn.net/Hit_the_lights/article/details/79704560 Java问答知识锦集 https://blog.csdn.net/huangshulang1234/article/details/79723945