Cygwin - ssh-keygen
- 生成 密钥对
ssh-keygen -t rsa -b 1024 -f yourkeyname -C "备注"
➜ ~ ssh-keygen -t rsa -b 1024
Generating public/private rsa key pair.
Enter file in which to save the key (/home/admin/.ssh/id_rsa):
Created directory '/home/admin/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/admin/.ssh/id_rsa
Your public key has been saved in /home/admin/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:TwXo21OYoHyTRr/YvjoLcxLn/V8laKXxrPJjr5/eZ3M admin@LAPTOP-GJISTNUT
The key's randomart image is:
+---[RSA 1024]----+
| .. |
| + . |
| . + + oo . |
| o * +..B |
| .oS*.o+ + .|
| +o+=. . ..|
| + o.+.. .|
| =. .+o =E|
| o+.o+B*.=|
+----[SHA256]-----+
参数 解释
-b 采用长度1024bit的密钥对,b=bits,最长4096,不过没啥必要
-t rsa 采用rsa加密方式,t=type
-f 生成文件名,f=output_keyfiles
-C 备注,C=comment
- 同步公钥到服务器
➜ ~ ssh-copy-id root@192.168.1.8
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/admin/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
(root@192.168.1.8) Password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.1.8'"
and check to make sure that only the key(s) you wanted were added.