【linux ssh免密码登录】linux 免密码登录

vi /etc/hosts localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 node1 node2 node3

scp -r local_folder remote_username@remote_ip:remote_folder

scp -r /etc/hosts root@node2:/etc/hosts 将hosts文件传输到别的节点进行覆盖

假如 A 要登陆 B
ssh-keygen (提示时,直接回车即可)
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 (’ 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,’ (RSA) to the list of known hosts.
root@node1’s password:
Now try logging into the machine, with “ssh ‘node1’”, and check in:


to make sure we haven’t added extra keys that you weren’t expecting.

scp -r /usr/local/jdk-7u45 root@node2:/usr/local/
scp -r /etc/profile root@node2:/etc/profile

然后再在node2上面source /etc/profile

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页