id_rsa id_rsa.pub

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 2048]----+
|       .++.+ooo*+|
|       oooo.=oOo*|
|       .. o..@.o=|
|       ..+  O +. |
|        Soo+ *   |
|         =+ . + .|
|        o..  . E |
|         .      .|
|                 |
+----[SHA256]-----+

 

  在 /root 目录下多了两个文件,y 和 y.pub

[root@iz2ze5xd9ppdog0cch5vs0z ~]# pwd
/root
[root@iz2ze5xd9ppdog0cch5vs0z ~]# ls -al
total 128
dr-xr-x---. 12 root root  4096 Jul  7 20:10 .
dr-xr-xr-x. 18 root root  4096 Jun 15 19:52 ..
-rw-------   1 root root 16146 Jul  5 00:41 .bash_history
-rw-r--r--.  1 root root    18 Dec 29  2013 .bash_logout
-rw-r--r--.  1 root root   176 Dec 29  2013 .bash_profile
-rw-r--r--.  1 root root   176 Dec 29  2013 .bashrc
drwx------   5 root root  4096 Jun 20 21:11 .cache
drwxr-xr-x   5 root root  4096 Jul  4 00:10 code
drwx------   7 root root  4096 Jun 20 21:11 .config
-rw-r--r--.  1 root root   100 Dec 29  2013 .cshrc
-rw-------   1 root root    87 Jun 13 20:09 .dbshell
drwx------   3 root root  4096 Jun 20 03:02 .dbus
-rw-r--r--   1 root root   106 Jun 14 12:56 dump.rdb
drwx------   2 root root  4096 Jul  7 03:34 .gnupg
-rw-------   1 root root   314 Jun 20 03:02 .ICEauthority
drwxr-xr-x   3 root root  4096 Jun 20 02:44 .local
-rw-------   1 root root     0 Jun 13 13:38 .mongorc.js
-rw-------   1 root root    73 Jun 14 12:53 .mysql_history
drwxr-xr-x   2 root root  4096 Oct 15  2017 .pip
drwxr-----   3 root root  4096 Jun 13 13:23 .pki
-rw-r--r--   1 root root    64 Oct 15  2017 .pydistutils.cfg
-rw-------   1 root root   784 Jun 20 22:15 .rediscli_history
drwx------   2 root root  4096 Jun  5 00:43 .ssh
drwxr-xr-x   3 root root  4096 Jun 25 22:50 .subversion
-rw-r--r--.  1 root root   129 Dec 29  2013 .tcshrc
-rw-------   1 root root  5443 Jun 19 23:49 .viminfo
-rw-r--r--   1 root root    11 Jun 14 12:13 .vimrc
-rw-------   1 root root     0 Jun 20 03:02 .Xauthority
-rw-------   1 root root  1766 Jul  7 20:10 y
-rw-r--r--   1 root root   410 Jul  7 20:10 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@iz2ze5xd9pp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nJcpE6FWRuEfpk2H9MY
RkbdLHTaqmEhKW7KKBRJDBj+Td7MNcbtGRDHSoISC8ExYkPg7SZJVj3pwXrboPed
2AAF26DvThLdMBrCaBbxZgKJ/zUfmK6lMSoJ7sv56/qhRufpHMQeNNhzTISsbTBe
wmTcjiUl8x+txX5bkPRbeAGukqS9OnPbhat91R1hc6b59CBeKwMNsDb4u1ZFnxbf
Z3OcwQzK07jr64o2KlPwhtcG4jvq4cuIrYoZpvRicl6LsyvEkkoVggf2YYEE5Kmf
plLN/TnFstx5MTf7shZvF31LW+pa90bQAXc+kQVxw0g7fUlu58YVQPmSWJEHJXSa
6Vmy/AyX9Gw93ibTot77nAda5qPP63WZZhd+al7Vjz9lUwqP2d5Csfg4cFfW9ev6
Ht+m3SLs5SZsNoAERy4nrtGIlEN3KKAuseVGbwHFkyo7TYsF6eUdDdwiBBLlFztB
lCC7frq2V8x2kvSp7C1s9C7K5ItBS7y7Rh2EyU8e4WPoJzZ28to+KVigrG6xSLyq
wS5Hc2A6XnPybZLM9rCPniGzC7uD4fZNSBXPnaB4jzx8ViNM5HgA/mVOsCTp2sP4
ds+Ayy9P13lKFlCOmFVnh8pgn+GYsU8LVKZ0FiFZbEK6Y9CxOTE969lxKEpOD4fI
-----END RSA PRIVATE KEY-----

 

  查看authorized_keys

[root@iz2ze5xd9ppdog0cch5vs0z .ssh]# cd ~/.ssh/
[root@iz2ze5xd9ppdog0cch5vs0z .ssh]# ls -al
total 8
drwx------   2 root root 4096 Jun  5 00:43 .
dr-xr-x---. 12 root root 4096 Jul  7 20:10 ..
-rw-------   1 root root    0 Jun  5 00:43 authorized_keys
[root@iz2ze5xd9ppdog0cch5vs0z .ssh]# cat authorized_keys 

 

转载于:https://www.cnblogs.com/654321cc/p/9278312.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值