一 核心命令
- 创建密钥对:ssh-keygen
- 转发密钥:ssh-copy-id -i ~/.ssh/id_rsa.pub puppet@Hadoop-NN-02
- ssh-keygen -t dsa
- ssh-keygen -t rsa
- ssh-keygen -t rsa1
[puppet@BigData-01 cdh4.4]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/puppet/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/puppet/.ssh/id_rsa. Your public key has been saved in /home/puppet/.ssh/id_rsa.pub. The key fingerprint is: af:e2:f5:3a:e8:24:64:c1:f3:d9:bc:44:3d:9a:84:a0 puppet@BigData-01 The key's randomart image is: +--[ RSA 2048]----+ | . | | o . . . | | E + . o o | | + * o . | | o o S | | o . o | | . ..o . | | oo..o | | oo.oo. | +-----------------+ |
[puppet@BigData-01 .ssh]$ cat id_rsa.pub 6LfMzLguf90uw+4ZKpYgxN4XSbbLbu1MPFLLqFxlo7oC2TOhhr84N1Zdm8jtfuh53IhNZDHKpvByUHS4ZZV YVtAKt3+fZOEL700+p228JdQzkzfLHoaPvSD774igY+yB4d3pXkqk+fUALkE2H1hgbfJNjMoar5lls6KfdF6ocL KBILj56Lt+b9KhVtPbllsP8TA8Vino9eF1TeCdKnRmxBFdYTBFlx8s1gRx2VHQnwVpUJcUuVPyGaxvPNXvL HtPZPwi3xJmSFpPB9y8pzID1WqDKKAWkv7CcJqstIhBN3w==puppet@BigData-01 |
[puppet@BigData-01 .ssh]$ cat id_rsa -----BEGIN RSA PRIVATE KEY----- MIIEoQIBAAKCAQEA8CscWlgavdb76EVfhZadM4uMBzN8iVMEC0KuTHdGCzm6LfMz Lguf90uw+4ZKpYgxN4XSbbLbu1MPFLLqFxlo7oC2TOhhr84N1Zdm8jtfuh53IhNZ DHKpvByUHS4ZZVYVtAKt3+fZOEL700+p228JdQzkzfLHoaPvSD774igY+yB4d3pX kqk+fUALkE2H1hgbfJNjMoar5lls6KfdF6ocLKBILj56Lt+b9KhVtPbllsP8TA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h8zphOcd6ECIQz5LKEx JSJ+oCs7GZDoxTI/w8dhrLrZDrBYjUkM1uX3xNfFK+2gH5zBlMCEBQbWh5l7/JNE kR0CgYA3ip6Mo+6iXLeXmsSwT+p3CGDdZe1SsQElLDDgOZvMEpy8wzZ1sIKYY0Oe lsc23TrC+BHoJHaMKa9CHuZTwdQXGQuVam313WaGtD/3q6Inq6PosQj60v02jogx rsfnG3WOSygeNS03PEflKpf6k5A0b3EZyZ5gatql/7I4D/3MPA== -----END RSA PRIVATE KEY----- |
[puppet@BigData-01 .ssh]$ ssh-copy-id -i ~/.ssh/id_rsa.pub puppet@Hadoop-NN-02 puppet@hadoop-nn-02's password: Now try logging into the machine, with "ssh 'puppet@Hadoop-NN-02'", and check in: .ssh/authorized_keys to make sure we haven't added extra keys that you weren't expecting. |
[puppet@BigData-02 .ssh]$ cat authorized_keys LfMzLguf90uw+4ZKpYgxN4XSbbLbu1MPFLLqFxlo7oC2TOhhr84N1Zdm8jtfuh53IhNZDHKpvByUHS4ZZVY VtAKt3+fZOEL700+p228JdQzkzfLHoaPvSD774igY+yB4d3pXkqk+fUALkE2H1hgbfJNjMoar5lls6KfdF6ocLK BILj56Lt+b9KhVtPbllsP8TA8Vino9eF1TeCdKnRmxBFdYTBFlx8s1gRx2VHQnwVpUJcUuVPyGaxvPNXvLHt PZPwi3xJmSFpPB9y8pzID1WqDKKAWkv7CcJqstIhBN3w==puppet@BigData-01 |
[puppet@BigData-01 .ssh]# sshpuppet@BigData-02 @@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ <==警告有问题 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@ |