SSH-免密码互相远程登录
2015-10-01 17:03
190 查看
linux多节点之间可以实现无密码SSH相互远程登录。原理就是在每一个节点上面用ssky-keygen生成自己的公钥和私钥,然后再把自己的公钥分别导入到其它节点上面,就可以实现无密码远程登录了。
ssh-keygen 创建公钥和密钥。
ssh-copy-id 把本地主机的公钥复制到远程主机的authorized_keys文件上。
ssh-copy-id 也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限 。
(1)用 ssh-key-gen 在本地主机上创建公钥和密钥
ligh@local-host$ ssh-keygen -t rsa
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9
(2)用 ssh-copy-id 把公钥复制到远程主机上
ligh@local-host$ssh-copy-id
-i ~/.ssh/id_rsa.pub root@192.168.0.3
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
注: ssh-copy-id 可把公钥密钥追加到远程主机的 .ssh/authorized_key文件中
如果提示:-bash: ssh-copy-id: command not found 是说明在改系统上没有该命令,此命令是由openssh-clients包安装的,在操作系统的光碟中有此包,也可以yum install openssh-clients安装。
[root@centos ~]# which ssh-copy-id
/usr/bin/ssh-copy-id
[root@centos ~]# rpm -qf /usr/bin/ssh-copy-id
openssh-clients-5.3p1-84.1.el6.x86_64
(3) 远程登入
ligh@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
注: SSH 不会询问密码了即可远程登录主机
ssh-keygen 创建公钥和密钥。
ssh-copy-id 把本地主机的公钥复制到远程主机的authorized_keys文件上。
ssh-copy-id 也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限 。
(1)用 ssh-key-gen 在本地主机上创建公钥和密钥
ligh@local-host$ ssh-keygen -t rsa
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9
(2)用 ssh-copy-id 把公钥复制到远程主机上
ligh@local-host$ssh-copy-id
-i ~/.ssh/id_rsa.pub root@192.168.0.3
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
注: ssh-copy-id 可把公钥密钥追加到远程主机的 .ssh/authorized_key文件中
如果提示:-bash: ssh-copy-id: command not found 是说明在改系统上没有该命令,此命令是由openssh-clients包安装的,在操作系统的光碟中有此包,也可以yum install openssh-clients安装。
[root@centos ~]# which ssh-copy-id
/usr/bin/ssh-copy-id
[root@centos ~]# rpm -qf /usr/bin/ssh-copy-id
openssh-clients-5.3p1-84.1.el6.x86_64
(3) 远程登入
ligh@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
注: SSH 不会询问密码了即可远程登录主机
相关文章推荐
- 八大排序算法(Python实现)
- iOS GET请求和POST请求
- Objective-C中一种消息处理方法performSelector: withObject:
- PAT1006 换个格式输出整数
- 我和刘强东的故事2:这次是真的
- matlab图像显示程序模板
- Linux 命令 - alias: 设置或显示别名
- hdu 5479(括号问题)
- 理性的来源
- hdu 5479(括号问题)
- 第四节 一维数组
- Linux下Mongodb安装和启动配置
- C++命名空间
- uva 11992 线段树
- Another Look at Events(再谈Events)
- DNS学习总结
- ubuntu安装eclipse tomcat的参考网址
- 《Hadoop: The Definitive Guide》读书笔记 -- Chapter 1 Meet Hadoop
- 给cin/cout提速
- 数据结构的基本类型