[root@Linux01 ~]# ssh-keygen #生成公私钥 [root@Linux01 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub hadoopuser@Hadoop-NN-01 #将公钥扔到对方服务器
-I 表示 input
~/.ssh/id_rsa.pub 表示哪个公钥组
省略写法为:
[root@Linux01 ~]# ssh-copy-id Hadoop-NN-01 #将公钥扔到对方服务器 或写IP:10.10.51.231 [root@Linux01 ~]# ssh-copy-id ”6000 Hadoop-NN-01” #如果带端口则这样写
测试:
[root@Linux01 ~]# ssh Hadoop-NN-01 #验证(退出当前连接命令:exit、logout) [root@Linux01 ~]# ssh Hadoop-NN-01 –p 6000 #如果带端口这样写