构建ssh信任关系

构建ssh信任关系 之前的配置也是可以的,但是我们为了统一 重新再来一次配置
[hadoop@hadoop002 ~]$ rm -rf .ssh
[hadoop@hadoop002 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
Created directory '/home/hadoop/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
ca:e4:a1:fc:9f:e2:86:e7:9c:ab:f2:19:7a:70:c5:3d hadoop@hadoop002
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| . . |
| o E |
| .o S. |
| ...= o |
| o+.+ |
| ..o=+. . |
| .++*B+o |
+-----------------+
[hadoop@hadoop002 ~]$ cd .ssh
[hadoop@hadoop002 .ssh]$ ll
total 8
-rw------- 1 hadoop hadoop 1675 Feb 16 20:27 id_rsa
-rw-r--r-- 1 hadoop hadoop 398 Feb 16 20:27 id_rsa.pub
[hadoop@hadoop002 .ssh]$ cat id_rsa.pub >> authorized_keys
[hadoop@hadoop002 .ssh]$
[hadoop@hadoop002 .ssh]$ ll
total 12
-rw-rw-r-- 1 hadoop hadoop 398 Feb 16 20:27 authorized_keys
-rw------- 1 hadoop hadoop 1675 Feb 16 20:27 id_rsa
-rw-r--r-- 1 hadoop hadoop 398 Feb 16 20:27 id_rsa.pub
[hadoop@hadoop002 .ssh]$
[hadoop@hadoop002 .ssh]$
[hadoop@hadoop002 .ssh]$
[hadoop@hadoop002 .ssh]$
[hadoop@hadoop002 .ssh]$ cd
[hadoop@hadoop002 ~]$ cd app/hadoop-2.6.0-cdh5.7.0
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ sbin/start-dfs.sh
19/02/16 20:28:25 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [hadoop002]
The authenticity of host 'hadoop002 (172.31.236.240)' can't be established.
RSA key fingerprint is b1:94:33:ec:95:89:bf:06:3b:ef:30:2f:d7:8e:d2:4c.
Are you sure you want to continue connecting (yes/no)? yes
hadoop002: Warning: Permanently added 'hadoop002,172.31.236.240' (RSA) to the list of known hosts.
hadoop@hadoop002's password:

[2]+ Stopped sbin/start-dfs.sh
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ ^C
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ jps
962 Jps
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ ps -ef|grep start-dfs.sh
hadoop 790 349 0 20:25 pts/0 00:00:00 bash sbin/start-dfs.sh
hadoop 887 349 0 20:28 pts/0 00:00:00 bash sbin/start-dfs.sh
hadoop 977 349 0 20:28 pts/0 00:00:00 grep start-dfs.sh
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ kill -9 790 887
[hadoop@hadoop002 hadoop-2.6.0-cdh5.7.0]$ cd
[1]- Killed sbin/start-dfs.sh (wd: ~/app/hadoop-2.6.0-cdh5.7.0)
(wd now: ~)
[2]+ Killed sbin/start-dfs.sh (wd: ~/app/hadoop-2.6.0-cdh5.7.0)
(wd now: ~)
[hadoop@hadoop002 ~]$ cd .ssh
[hadoop@hadoop002 .ssh]$ ll
total 16
-rw-rw-r-- 1 hadoop hadoop 398 Feb 16 20:27 authorized_keys
-rw------- 1 hadoop hadoop 1675 Feb 16 20:27 id_rsa
-rw-r--r-- 1 hadoop hadoop 398 Feb 16 20:27 id_rsa.pub
-rw-r--r-- 1 hadoop hadoop 406 Feb 16 20:28 known_hosts
[hadoop@hadoop002 .ssh]$ chmod 600 authorized_keys
[hadoop@hadoop002 .ssh]$
[hadoop@hadoop002 .ssh]$ cd -
/home/hadoop
[hadoop@hadoop002 ~]$ cd app/hadoop-2.6.0-cdh5.7.0

原文地址:https://www.cnblogs.com/xuziyu/p/10403408.html