一、在192.168.75.130上操作 1、在~/.ssh目录下产生公钥与私钥对. # 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:
e4:bb:24:9c:f9:01:a8:80:4d:db:66:5b:47:48:c5:ca root@slave0.localdomain.com
The key's randomart image is:
+--[ RSA 2048]----+
| .o. |
| . .. |
| . ...o |
|.o o .E+ |
|o o = o S |
| . + + = . |
| . . = + |
| + o |
| o |
+-----------------+
2、ssh-copy-id 将公钥id_rsa.pub的内容追加到远程机器的 ~/ .ssh/authorized_key.文件中 # ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.75.128
root@192.168.75.128's password:
Now try logging into the machine, with "ssh '192.168.75.128'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
二、192.168.75.128 上做同样的操作
1、在~/.ssh目录下产生公钥与私钥对.
# 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:
e4:bb:24:9c:f9:01:a8:80:4d:db:66:5b:47:48:c5:ca root@slave0.localdomain.com
The key's randomart image is:
+--[ RSA 2048]----+
| .o. |
| . .. |
| . ...o |
|.o o .E+ |
|o o = o S |
| . + + = . |
| . . = + |
| + o |
| o |
+-----------------+
2、ssh-copy-id 将公钥id_rsa.pub的内容追加到远程机器的 ~/ .ssh/authorized_key.文件中
# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.75.130
root@192.168.75.130's password:
Now try logging into the machine, with "ssh '192.168.75.130'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.