[hduser@localhost ~]$ ssh-keygen -t rsa -P "" Generating public/private rsa key pair. Enter file inwhich to save the key (/home/hduser/.ssh/id_rsa): Created directory '/home/hduser/.ssh'. Your identification has been saved in /home/hduser/.ssh/id_rsa. Your public key has been saved in /home/hduser/.ssh/id_rsa.pub. The key fingerprint is: 55:06:d8:e8:20:75:1c:d0:f9:7e:83:16:9f:89:4d:8b hduser@localhost.localdomain The key's randomart image is: +--[ RSA 2048]----+ | .o+o*..o | | . ..* .o | | . o .. | | ..o . | | S. O + | | E O | | . . . | | | | | +-----------------+
以上命令执行完成之后会生成一个空密码的RSA密钥对(空密码是为了避免每次登陆时输入密码)。
1 2
[hduser@localhost .ssh]$ ls id_rsa id_rsa.pub
然后,你需要启用刚刚创建的密钥来通过SSH访问你的服务器。
1
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
最后测试SSH的设置是否正确
1 2 3 4 5 6
[hduser@localhost .ssh]$ ssh localhost The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is a6:35:b9:b9:43:4f:b2:8b:29:e2:89:35:b5:ae:18:c9. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. Last login: Tue Oct 31 02:21:24 2017
...... # The only required environment variable is JAVA_HOME. All others are # optional. When running a distributed configuration it is best to # set JAVA_HOME in this file, so that it is correctly defined on # remote nodes.
# The java implementation to use. export JAVA_HOME=/storage/jre/jdk1.8.0_151 ......
<configuration> <property> <name>hadoop.tmp.dir</name> <value>/storage/hadoop-2.8.2/tmp</value> <description>A base for other temporary directories.</description> </property>
<property> <name>fs.defaultFS</name> <value>hdfs://localhost:9000</value> <description>The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation. The uri's scheme determines the config property (fs.SCHEME.impl) naming the FileSystem implementation class. The uri's authority is used to determine the host, port, etc. for a filesystem.</description> </property> </configuration>