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