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

来源:互联网 发布:模拟视频信号传输网络 编辑:程序博客网 时间:2024/05/18 12:37

**配置主机之间的免密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

原创粉丝点击