id_rsa 私钥
id_rsa.pub 公钥
https://blog.csdn.net/qq_36663951/article/details/78749217
https://blog.csdn.net/diyxiaoshitou/article/details/52471097
id_rsa.pub 的作用
上班的第一天,上司大哥都会说:待会给我发个公钥吧。 这里说的公钥其实就是id_rsa.pub。上司大哥是要把我们的客户端公钥上传到服务器,然后再把这个客户端公钥添加到authorized_keys。添加后,服务器就会认为你这个客户端为可信任。你则可以访问这个服务器了。
个人阿里云测试:
[root@iz2ze5xd9ppdog0cch5vs0z ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in y.
Your public key has been saved in y.pub.
The key fingerprint is:
SHA256:fI5TxBpVS199BCl8lmo21bY1MC4hI5mlv3G3QVto+5M root@iz2ze5xd9ppdog0cch5vs0z
The key's randomart image is:
+---[RSA ]----+
| .++.+ooo*+|
| oooo.=oOo*|
| .. [email protected]=|
| ..+ O +. |
| Soo+ * |
| =+ . + .|
| o.. . E |
| . .|
| |
+----[SHA256]-----+
在 /root 目录下多了两个文件,y 和 y.pub
[root@iz2ze5xd9ppdog0cch5vs0z ~]# pwd
/root
[root@iz2ze5xd9ppdog0cch5vs0z ~]# ls -al
total
dr-xr-x---. root root Jul : .
dr-xr-xr-x. root root Jun : ..
-rw------- root root Jul : .bash_history
-rw-r--r--. root root Dec .bash_logout
-rw-r--r--. root root Dec .bash_profile
-rw-r--r--. root root Dec .bashrc
drwx------ root root Jun : .cache
drwxr-xr-x root root Jul : code
drwx------ root root Jun : .config
-rw-r--r--. root root Dec .cshrc
-rw------- root root Jun : .dbshell
drwx------ root root Jun : .dbus
-rw-r--r-- root root Jun : dump.rdb
drwx------ root root Jul : .gnupg
-rw------- root root Jun : .ICEauthority
drwxr-xr-x root root Jun : .local
-rw------- root root Jun : .mongorc.js
-rw------- root root Jun : .mysql_history
drwxr-xr-x root root Oct .pip
drwxr----- root root Jun : .pki
-rw-r--r-- root root Oct .pydistutils.cfg
-rw------- root root Jun : .rediscli_history
drwx------ root root Jun : .ssh
drwxr-xr-x root root Jun : .subversion
-rw-r--r--. root root Dec .tcshrc
-rw------- root root Jun : .viminfo
-rw-r--r-- root root Jun : .vimrc
-rw------- root root Jun : .Xauthority
-rw------- root root Jul : y
-rw-r--r-- root root Jul : y.pub
查看
[root@iz2ze5xd9ppdog0cch5vs0z ~]# cat y.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGVjc7/p/5l0U4bniHBozg5t7sHMhLFfIGf17GoZaWA5OPflRBMr3YrJ1uvigNrzhEIZGvYnb6W+coUHuV9wu9ht6DvIkcFVSQsv/IEi/GbdkAonTH7/MlehYw7rv6FcXF635Re5hD8fFrci8pMTdv++IR5eDtjVHmhl+QNAUKpnNC+GkPyNSvtxxZxURKs0Qj8hFamKIIAdqWKZlyRBk7J6DghVzugfDKrDnkRCcLQ2YhSH90BBzbqngJP23nhRsLG4NN1MObQY/3bXL0k7EBWT1JfJN/zAyeWEV9ElyqBBkdUDs+2A69LO39WfhAwgIVPgzuLpxPHtDMrbtjGH8f root@iz2ze5xd9ppdog0cch5vs0z
[root@iz2ze5xd9ppdog0cch5vs0z ~]# cat y
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: ,ENCRYPTED
DEK-Info: AES--CBC,D83C1DCD5C2C7E2797BBB6C4E8A02CA0 OlerAfyNyW6h8gmhd+ii95WxUnpr8TiSs00ckgjDxMnWQw0LZh8bYcfXTzJWOQKH
/K+kxJSHpDgVHaUCwuKGfP8iORhqpF2/ADIeg1cVRh13FWv9D7RT9SLJEILMcL5
M5IrJJpSMby/N+db3DCjKMzIgg5ZJeGleQ8Xmwke/4Ro2SZFZaUm1I8oZY3E2HXC
kzoSN5w+E97DqS3mDcqw4RbV3b6i8aMlAPPOqOt2X2gNgclolC2D2I9NWCOOAjWQ
CoLckxjvoVC1o7BDHbmvJg8qpzcI/G9im+/AW7UgiBPBHC4JWuuU4rfm3dB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EN3KKAuseVGbwHFkyo7TYsF6eUdDdwiBBLlFztB
lCC7frq2V8x2kvSp7C1s9C7K5ItBS7y7Rh2EyU8e4WPoJzZ28to+KVigrG6xSLyq
wS5Hc2A6XnPybZLM9rCPniGzC7uD4fZNSBXPnaB4jzx8ViNM5HgA/mVOsCTp2sP4
ds+Ayy9P13lKFlCOmFVnh8pgn+GYsU8LVKZ0FiFZbEK6Y9CxOTE969lxKEpOD4fI
-----END RSA PRIVATE KEY-----
查看authorized_keys
[root@iz2ze5xd9ppdog0cch5vs0z .ssh]# cd ~/.ssh/
[root@iz2ze5xd9ppdog0cch5vs0z .ssh]# ls -al
total
drwx------ root root Jun : .
dr-xr-x---. root root Jul : ..
-rw------- root root Jun : authorized_keys
[root@iz2ze5xd9ppdog0cch5vs0z .ssh]# cat authorized_keys