操作步骤:

1.主机A

生成公钥id_rsa.pub文件并导出该文件

root@mytest:~# ssh-keygen
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:
7e:0f:dc::2e:d3:e0::c0:5f:fe:cf:e9:7a:f7: root@mytest
The key's randomart image is:
+--[ RSA ]----+
| .. |
| .. . |
| ..oo . |
| .+.+ . |
| S +.o . |
| . . +.. |
| . + .o E |
| . o * o|
| o+.oo|
+-----------------+
root@mytest:~# sz /root/.ssh/id_rsa.pub

这步之后也可以通过以下步骤直接实现公钥认证(但是需要知道主机B用户danny的密码)

# ssh-copy-id -i /root/.ssh/id_rsa.pub danny@12.1.1.2
danny@12.1.1.2's password: //输入主机B用户danny的登录密码

2.主机B

得到id_rsa.pub文件,创建用户danny,并在该用户家目录创建.ssh文件夹和其文件下的远程认证文件authorized_keys

[root@B danny]# mkdir .ssh
[root@B danny]# cd .ssh/
[root@B .ssh]# touch authorized_keys
[root@B .ssh]# ls
authorized_keys
[root@B .ssh]# cat /home/danny/id_rsa.pub >authorized_keys

主机A登录主机B

root@mytest:/# ssh danny@IP_B

最新文章

  1. 第一章-第十三题(该游戏团队, 有很好的软件,但是商业模式和其他软件之外的因素有没有考虑到?)--By梁旭晖
  2. NodeJS Hello world
  3. Parameter Config
  4. ubuntu下nagios配置
  5. eWebeditor编辑器上传图片的设置程序
  6. JSON:org.json的基本用法
  7. Cocos2d-JS使用CocosDenshion引擎
  8. Any Way You Slice It (向量旋转 以及 判断线段是否相交)(模板)
  9. [BZOJ 1874] [BeiJing2009 WinterCamp] 取石子游戏 【博弈论 | SG函数】
  10. python:时间处理模块
  11. Direct3D 索引缓存
  12. 【转】C++实现RTMP协议发送H.264编码及AAC编码的音视频
  13. 模拟new实例化对象。
  14. GameUnity 2.0 文档(五) 人工智能之---------------Flocking算法 (聚集,分散,列队 )
  15. 升级PyCham到2017.3后import sys模块报错的问题
  16. scp传输提示bash: scp: command not found
  17. 内联元素于与块元素的转换 相对定位、绝对定位以及fixed定位 Z轴覆盖
  18. 【hdu 4658】Integer Partition (无序分拆数、五边形数定理)
  19. tkinter拦截关闭事件
  20. Oracle 11G 安装图文教程

热门文章

  1. Leetcode:234 回文链表
  2. php 乱整
  3. redis学习(九)——数据持久化
  4. 【开源】 bsf.mvc spingboot的扩展
  5. CF960G Bandit Blues 第一类斯特林数、NTT、分治/倍增
  6. ReactJs入门教程-精华版
  7. 一篇 SpringData+JPA 总结
  8. 剑指offer 第十一天
  9. C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 发送通知功能改进改进
  10. Jvm 参数笔记