ssh两台主机建立信任关系
2024-08-28 17:16:35
A主机(10.104.11.107) B主机(10.104.11.128)
A: ssh-keygen -t rsa
[root@H0f .ssh]# 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
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:
c3:41:52:b3:6c:0e:ca:37:87:c6:18:7c:80:6e:fb:1e root@H0f
The key's randomart image is:
+--[ RSA 2048]----+
| .. ..+ |
| .. . + o |
| . o o = |
| o. * * . |
| . .+ * S |
| . o o . |
| .E |
| .. |
| .. |
+-----------------+
[root@H0f .ssh]# ll
total 12
-rw-------. 1 root root 1743 Mar 26 03:06 id_rsa #密钥
-rw-r--r--. 1 root root 390 Mar 26 03:06 id_rsa.pub #公钥
-rw-r--r--. 1 root root 395 Mar 26 03:08 known_hosts
[root@H0f .ssh]# scp -r id_rsa.pub 10.104.11.107:/root/.ssh/authorized_keys
root@10.104.11.107's password: #输入主机B的登录密码
id_rsa.pub
B:ssh-keygen -t rsa
[root@H0f .ssh]# 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
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:
c3:41:52:b3:6c:0e:ca:37:87:c6:18:7c:80:6e:fb:1e root@H0f
The key's randomart image is:
+--[ RSA 2048]----+
| .. ..+ |
| .. . + o |
| . o o = |
| o. * * . |
| . .+ * S |
| . o o . |
| .E |
| .. |
| .. |
+-----------------+
[root@H0f .ssh]# ll
total 16
-rw-r--r-- 1 root root 390 Mar 26 04:00 authorized_keys
-rw------- 1 root root 1743 Mar 26 04:02 id_rsa
-rw-r--r-- 1 root root 390 Mar 26 04:02 id_rsa.pub
-rw-r--r-- 1 root root 395 Mar 26 03:10 known_hosts
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /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:
c3:41:52:b3:6c:0e:ca:37:87:c6:18:7c:80:6e:fb:1e root@H0f
The key's randomart image is:
+--[ RSA 2048]----+
| .. ..+ |
| .. . + o |
| . o o = |
| o. * * . |
| . .+ * S |
| . o o . |
| .E |
| .. |
| .. |
+-----------------+
[root@H0f .ssh]# ll
total 16
-rw-r--r-- 1 root root 390 Mar 26 04:00 authorized_keys
-rw------- 1 root root 1743 Mar 26 04:02 id_rsa
-rw-r--r-- 1 root root 390 Mar 26 04:02 id_rsa.pub
-rw-r--r-- 1 root root 395 Mar 26 03:10 known_hosts
[root@H0f .ssh]# scp -r id_rsa.pub 10.104.11.128:/root/.ssh/authorized_keys
root@10.104.11.128's password:
id_rsa.pub
[root@H0f .ssh]# ssh 10.104.11.128 #建立连接
Enter passphrase for key '/root/.ssh/id_rsa':
Last login: Mon Mar 26 02:56:59 2018 from 10.104.10.85
[root@H0f ~]# ls
1_shell.sh 3_shuzu.sh anaconda-ks.cfg Documents if.sh Music Templates Videos
2_shell.sh a_array.sh danted_install.sh Downloads install.log Pictures testa
2.txt aha_array.sh Desktop if_file.sh install.log.syslog Public test.txt
Enter passphrase for key '/root/.ssh/id_rsa':
Last login: Mon Mar 26 02:56:59 2018 from 10.104.10.85
[root@H0f ~]# ls
1_shell.sh 3_shuzu.sh anaconda-ks.cfg Documents if.sh Music Templates Videos
2_shell.sh a_array.sh danted_install.sh Downloads install.log Pictures testa
2.txt aha_array.sh Desktop if_file.sh install.log.syslog Public test.txt
最新文章
- Matrix
- django-cms安装
- Android ActionBar以及menu的代码设置样式
- C语言中inline的用法
- 【转】android 选取图片
- BlockingQueue-线程的阻塞队列
- Linux----给一个普通用户root权限
- 使用VS+VisualGDB编译Linux版本RCF(相当于Linux也有COM版本了)
- Linux:最终用途cat命令查看不可见的字符
- 一次基于Vue.Js用户体验的优化
- Vue 爬坑之路(二)—— 组件之间的数据传递
- Nginx 配置HTTPS 与Node.js 配置HTTPS方法
- acm--博弈入门2(P/N分析)--(HDU 1847 HDU 2188 HDU 3863)
- 自学Aruba3.1-Aruba配置架构-WLAN配置架构
- Docker三剑客之Docker Machine
- 阿里云ECS服务器源配置
- openssl证书及配置
- python中map()函数
- Luogu 3690 Link Cut Tree
- Gridview中实现求和统计功能