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

[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

最新文章

  1. Matrix
  2. django-cms安装
  3. Android ActionBar以及menu的代码设置样式
  4. C语言中inline的用法
  5. 【转】android 选取图片
  6. BlockingQueue-线程的阻塞队列
  7. Linux----给一个普通用户root权限
  8. 使用VS+VisualGDB编译Linux版本RCF(相当于Linux也有COM版本了)
  9. Linux:最终用途cat命令查看不可见的字符
  10. 一次基于Vue.Js用户体验的优化
  11. Vue 爬坑之路(二)—— 组件之间的数据传递
  12. Nginx 配置HTTPS 与Node.js 配置HTTPS方法
  13. acm--博弈入门2(P/N分析)--(HDU 1847 HDU 2188 HDU 3863)
  14. 自学Aruba3.1-Aruba配置架构-WLAN配置架构
  15. Docker三剑客之Docker Machine
  16. 阿里云ECS服务器源配置
  17. openssl证书及配置
  18. python中map()函数
  19. Luogu 3690 Link Cut Tree
  20. Gridview中实现求和统计功能

热门文章

  1. li ol ul是什么的简写?
  2. p2444 病毒
  3. Excel课程学习
  4. DiscreteFrechetDist
  5. Redis实现用户关注功能
  6. vue2.x学习笔记
  7. unity list循环
  8. 提取pfx证书公钥和私钥
  9. c++类 初始化const数据成员
  10. ubuntu - 14.04,如何让从托盘消失的输入法图标再次显示出来?