請在linux701下
ssh-keygen,如過出現無法找到,請先安裝yum install y openssh-clients
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
上述定義私密金鑰得存取路徑,預設路徑為/root/.ssh/id_rsa,我們預設就好,按enter
出現
Enter passphrase (empty for no passphrase):
表示定義私密金鑰的密碼,我們按enter(空白),出現
Enter same passphrase again:
再輸入一次,按enter
出現
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:
SHA256:FTpHJH7oVVVEoxSV0ExyyPzLnJxkusS9xzYc4xrqfRM root@su-138.localdomain
The key's randomart image is:
+---[RSA 2048]----+
| ..+ +*XO=|
| . = o.+++.|
| = = .. |
| . * + |
| S . O +|
| + E |
| ..+.=|
| o..B+|
| .o oo.+|
+----[SHA256]-----+
這樣就產生了,公開金鑰放在/root/.ssh/id_rsa.pub,私密金鑰放在/root/.ssh/id_rsa
進去看公開金鑰
vi /root/.ssh/id_rsa.pub,將裡面得字串copy起來,複製到另一台linux702的
/root/.ssh/authorized_keys,如果出現沒有此目錄,就先建mkdir /root/.ssh目錄,再下
vi /root/.ssh/authorized_keys ,貼上公開金鑰的字串在存檔(:wq!),然後再下
chmod 600 /root/.ssh/authorized_keys
在linux701下
ssh IP(linux702的IP),第一次會問密碼就按enter,之後就不會問了
沒有留言:
張貼留言