ssh免密码登陆
2016-03-13 22:54
295 查看
Ssh免密码登陆设置
准备工作:1.确保两个主机里没有id_rsa.pub和authorized_keys的文件(这两个文件会影响实验的结果)# find / -name id_rsa.pub可查看是否有这个文件。
2.两个主机已安装ssh # rpm -qa |grep openssh 可查看是否安装ssh的相关包
说明:A(192.168.1.106)B(192.168.1.11)
一、A主机执行ssh-keygen
[root@A ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
75:06:e4:cb:25:67:5e:32:fb:9e:28:0a:24:09:18:aa root@lxh
The key's randomart image is:
+--[ RSA 2048]----+
|. .o |
|.o . . |
|o . + O . |
|. . . o X = |
|E o . S o o |
| o . |
| . . |
| . . o . |
| .. .. o |
+-----------------+
二、在B主机建立文件夹
[root@B~]# mkdir /root/.ssh
三、在A主机传送文件
[root@A ~]# scp /root/.ssh/id_rsa.pub root@192.168.1.111:/root/.ssh/authorized_keys
root@192.168.1.111's password:
id_rsa.pub
四、在A主机连接B主机
[root@A ~]# ssh root@192.168.1.111
Last login: Sun Mar 13 22:31:50 2016 from 192.168.1.106
[root@B ~]#
这样就不用输入密码成功连接到B主机了,输入exit退出B主机返回A主机。
[root@A ~]# ssh 192.168.1.111 ls
anaconda-ks.cfg
install.log
install.log.syslog
这样可以直接用B主机执行命令在A主机显示。
准备工作:1.确保两个主机里没有id_rsa.pub和authorized_keys的文件(这两个文件会影响实验的结果)# find / -name id_rsa.pub可查看是否有这个文件。
2.两个主机已安装ssh # rpm -qa |grep openssh 可查看是否安装ssh的相关包
说明:A(192.168.1.106)B(192.168.1.11)
一、A主机执行ssh-keygen
[root@A ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
75:06:e4:cb:25:67:5e:32:fb:9e:28:0a:24:09:18:aa root@lxh
The key's randomart image is:
+--[ RSA 2048]----+
|. .o |
|.o . . |
|o . + O . |
|. . . o X = |
|E o . S o o |
| o . |
| . . |
| . . o . |
| .. .. o |
+-----------------+
二、在B主机建立文件夹
[root@B~]# mkdir /root/.ssh
三、在A主机传送文件
[root@A ~]# scp /root/.ssh/id_rsa.pub root@192.168.1.111:/root/.ssh/authorized_keys
root@192.168.1.111's password:
id_rsa.pub
四、在A主机连接B主机
[root@A ~]# ssh root@192.168.1.111
Last login: Sun Mar 13 22:31:50 2016 from 192.168.1.106
[root@B ~]#
这样就不用输入密码成功连接到B主机了,输入exit退出B主机返回A主机。
[root@A ~]# ssh 192.168.1.111 ls
anaconda-ks.cfg
install.log
install.log.syslog
这样可以直接用B主机执行命令在A主机显示。
相关文章推荐
- MVC设计模式
- STL-算法总结
- Class类文件加载机制
- linux-export
- fragment传值给Activity
- iOS使用AVFoundation实现二维码扫描
- python(5)- sys.stdout()实现进度条
- 学习Java第一天
- TinyHttp-最简单的Web Server浅析
- DialogFragment宽度问题处理
- OSChina 周一乱弹 ——你敢不敢跟我姐离婚 跟我浪迹天涯
- 银行客户排列问题
- 杭电oj 2019 数列有序
- 用python画三角形外接圆和内切圆
- jsp之request对象
- 设计模式七大原则
- https://github.com/wytings
- 汇编学习
- 迭代器模式
- C++:C++primer plus 指针问题理解