实现两台主机互相远程连接

[root@csa ~]# ssh-keygen -t rsa
[root@csa ~]# ll .ssh
总用量 8
-rw-------. 1 root root 2590  1月 10 19:14 id_rsa
-rw-r--r--. 1 root root  562  1月 10 19:14 id_rsa.pub
[root@csa ~]# ssh-copy-id 192.168.246.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.246.129 (192.168.246.129)' can't be established.
ED25519 key fingerprint is SHA256:4tj5Uoja53qI+8ti1TTKbYvO00wJDD2Itbfs1B/fnPk.
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

Authorized users only. All activities may be monitored and reported.
root@192.168.246.129's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.246.129'"
and check to make sure that only the key(s) you wanted were added.

[root@csa ~]# ll .ssh
总用量 20
-rw-------. 1 root root  580  1月 10 20:48 authorized_keys
-rw-------. 1 root root 2590  1月 10 19:14 id_rsa
-rw-r--r--. 1 root root  562  1月 10 19:14 id_rsa.pub
-rw-------. 1 root root  666  1月 10 20:42 known_hosts
-rw-r--r--. 1 root root   97  1月 10 20:42 known_hosts.old

[root@csa ~]# ssh 192.168.246.129

Authorized users only. All activities may be monitored and reported.

Authorized users only. All activities may be monitored and reported.
Last login: Tue Jan  9 12:26:11 2024 from 192.168.246.1


Welcome to 6.4.0-10.1.0.20.oe2309.x86_64

System information as of time: 	2024年 01月 09日 星期二 14:05:12 CST

System load: 	0.00
Processes: 	143
Memory used: 	20.9%
Swap used: 	0%
Usage On: 	6%
IP address: 	192.168.246.129
Users online: 	2


[root@localhost ~]#

[root@localhost ~]# ll .ssh
总计 4
-rw-------. 1 root root 562  1月 9日 14:02 authorized_keys
[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:dhiK9+MNReJ4z/OKggl3vbMPz9QTZU2e1oWIeLJIYBM root@localhost.localdomain
The key's randomart image is:
+---[RSA 3072]----+
|    Eo   . . . .o|
|   . .. o o . .++|
|     . .o+.   oo+|
|     ..+.=   o.  |
|    . +.S o .    |
|  . ...+.= . .   |
|   o +  =.= o    |
|    o ..oX o .   |
|       .++*..    |
+----[SHA256]-----+
[root@localhost ~]# ssh-copy-id 192.168.246.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.246.128 (192.168.246.128)' can't be established.
ED25519 key fingerprint is SHA256:gturpaY2lCuXCe5kPg4YEaH26+bZsJyA+fbkniUddhI.
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.246.128's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.246.128'"
and check to make sure that only the key(s) you wanted were added.
[root@localhost ~]# ll .ssh
总计 20
-rw-------. 1 root root  562  1月 9日 14:02 authorized_keys
-rw-------. 1 root root 2610  1月 9日 14:06 id_rsa
-rw-r--r--. 1 root root  580  1月 9日 14:06 id_rsa.pub
-rw-------. 1 root root  843  1月 9日 14:09 known_hosts
-rw-------. 1 root root   97  1月 9日 14:09 known_hosts.old
[root@localhost ~]# ssh 192.168.246.128
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: Wed Jan 10 19:13:06 2024 from 192.168.246.1
[root@csa ~]# 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值