1. Generate Key
ssh-keygen -t rsa -C "<填写自己方便识别的注释>" -b 4096
No problem on the implementation of the three spaces.
1. Fill three problem is to generate a key for the path name. 2 Fill custom passphrsa. 3 confirmation.
1 [root@localhost home]# ssh-keygen -t rsa -C "********" -b 4096 2 Generating public/private rsa key pair. 3 Enter file in which to save the key (/root/.ssh/id_rsa): 4 Enter passphrase (empty for no passphrase): 5 Enter same passphrase again: 6 Your identification has been saved in /root/.ssh/id_rsa. 7 Your public key has been saved in /root/.ssh/id_rsa.pub. 8 The key fingerprint is: 9 SHA256:oQYIN3KUkPmnCn0LrC25h5L0yVpiIvoHUgawDuyCKuE ************** 10 The key's randomart image is: 11 +---[RSA 4096]----+ 12 |*==. | 13 | = *. O | 14 | o +. . . | 15 | = + ... . | 16 | + Breakfast oo S | 17 | * o * .. | 18 | BEO = .. | 19 | # = + o | 20 | + * o. | 21 + ---- [SHA256] ----- +
2. The public and private keys generated in the directory /root/.ssh
. 1 [.ssh the root @ localhost] # pwd 2 /root/.ssh . 3 [.ssh the root @ localhost] -l # LS . 4 Total amount 12 is . 5 -rw -------. The root the root. 1 September 19, 3247 10:00 id_rsa # private key . 6 -rw-R & lt -.. 9 r--. 1 the root the root 746 dated 19 10:00 id_rsa.pub # public key . 7 -rw-R & lt -. 174. 9 r-- the root the root. 1 May 18 16:58 known_hosts
3. Copy the public key to the remote host /root/.ssh/ id_rsa.pub file and rename it to authorized_keys.
- scp /root/.ssh/id_rsa.pub root@远程ip:/root/.ssh/authorized_keys
or
- ssh-copy-id -i ~/.ssh/id_rsa.pub root@远程ip
Verify password
4. Connect
- remote ip ssh
5. Free confirm fingerprint machine (without addition of the known_hosts)
- ssh -o StrictHostKeyChecking = no remote ip