[置顶] 【linux ssh免密码登录】linux 免密码登录
2017-06-23 19:49
302 查看
**配置主机之间的免密ssh登陆
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.81.130 node1
192.168.81.131 node2
192.168.81.132 node3
scp -r local_folder remote_username@remote_ip:remote_folder
scp -r /etc/hosts root@node2:/etc/hosts 将hosts文件传输到别的节点进行覆盖
假如 A 要登陆 B
在A上操作:
%%首先生成密钥对
ssh-keygen (提示时,直接回车即可)
%%再将A自己的公钥拷贝并追加到B的授权列表文件authorized_keys中
ssh-copy-id B
每台机器都要相互的做
例子:
[root@node1 ~]# 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:
bd:93:26:5a:31:ae:40:13:6e:fd:38:94:7a:a8:be:76 root@node1
The key’s randomart image is:
+–[ RSA 2048]—-+
| |
| |
| . |
| . o . . |
| = + S . |
| o = + o o |
| + + = = |
| ..Eo = o . |
| o+o o |
+—————–+
[root@node1 ~]# ssh-copy-id node1
The authenticity of host ‘node1 (192.168.116.128)’ can’t be established.
RSA key fingerprint is 3f:f4:32:b4:24:1c:07:d3:55:d1:f5:1b:c2:7d:8c:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node1,192.168.116.128’ (RSA) to the list of known hosts.
root@node1’s password:
Now try logging into the machine, with “ssh ‘node1’”, and check in:
.ssh/authorized_keys
to make sure we haven’t added extra keys that you weren’t expecting.
将安装的jdk复制到别的机器上面
scp -r /usr/local/jdk-7u45 root@node2:/usr/local/
scp -r /etc/profile root@node2:/etc/profile
然后再在node2上面source /etc/profile
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.81.130 node1
192.168.81.131 node2
192.168.81.132 node3
scp -r local_folder remote_username@remote_ip:remote_folder
scp -r /etc/hosts root@node2:/etc/hosts 将hosts文件传输到别的节点进行覆盖
假如 A 要登陆 B
在A上操作:
%%首先生成密钥对
ssh-keygen (提示时,直接回车即可)
%%再将A自己的公钥拷贝并追加到B的授权列表文件authorized_keys中
ssh-copy-id B
每台机器都要相互的做
例子:
[root@node1 ~]# 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:
bd:93:26:5a:31:ae:40:13:6e:fd:38:94:7a:a8:be:76 root@node1
The key’s randomart image is:
+–[ RSA 2048]—-+
| |
| |
| . |
| . o . . |
| = + S . |
| o = + o o |
| + + = = |
| ..Eo = o . |
| o+o o |
+—————–+
[root@node1 ~]# ssh-copy-id node1
The authenticity of host ‘node1 (192.168.116.128)’ can’t be established.
RSA key fingerprint is 3f:f4:32:b4:24:1c:07:d3:55:d1:f5:1b:c2:7d:8c:3e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘node1,192.168.116.128’ (RSA) to the list of known hosts.
root@node1’s password:
Now try logging into the machine, with “ssh ‘node1’”, and check in:
.ssh/authorized_keys
to make sure we haven’t added extra keys that you weren’t expecting.
将安装的jdk复制到别的机器上面
scp -r /usr/local/jdk-7u45 root@node2:/usr/local/
scp -r /etc/profile root@node2:/etc/profile
然后再在node2上面source /etc/profile
相关文章推荐
- linux上配置ssh的无密码登录
- linux下设置了SSH免密码登录但还是需要输入密码的解决办法
- linux下设置了SSH免密码登录但还是需要输入密码的解决办法
- Linux登录ssh携带密码
- Linux下配置SSH免密码登录
- linux远程登录ssh免密码
- ssh-keygen+ssh-copy-id 在linux下实现ssh无密码登录访问
- Putty通过SSH证书免密码登录Linux
- Linux登录ssh携带密码
- linux创建ssh信任无密码登录
- 不输入密码ssh直接登录阿里云Linux主机
- Linux下SSH免密码登录
- 使用ssh不输入密码登录到Linux
- ssh免密码登录, 发送命令到多个Linux
- Linux无密码ssh登录服务器配置
- 如何设置SSH无密码登录远程Linux主机
- Linux系统下如何做到SSH免密码登录
- Linux下SSH免密码登录
- 不输入密码,ssh直接登录远程Linux主机
- ssh 实现linux/unix无密码远程登录