1.实现免密登录
实现免密登录首先要让一台主机直到另一台主机的公钥,那么就需要先生成公私钥,使用如下的命令进行操作:
(1) 命令生成rsa这一对公私钥:命令详细解释如下所示:
[root@rhcsa .ssh]# ssh-keygen -t rsa // 产生公私钥
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): // 保存到哪个文件中,默认root
Enter passphrase (empty for no passphrase): // 输入密码,可以为空
Enter same passphrase again: //再次输入密码,与上面同步;
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:IMIXWKnZK+Cugc5h4ya/J1sHYAlrxKVTK1kQenjn8UQ root@rhcsa
The key's randomart image is:
+---[RSA 2048]----+
|o++*o.E | //此图即为rsa一对公私钥的结果
|o**.oo |
|+*O== o |
|o+=*.= . |
|.. o.. S |
|... .. |
|++ .. . |
|*++... |
|==+= |
+----[SHA256]-----+ // 采用哈希算法
[root@rhcsa .ssh]# ls // 再次查看已经生成了rsa公钥和私钥(.pub)
authorized_keys id_rsa.pub id_rsa known_hosts
[root@rhcsa .ssh]#
(2)下一步蒋公钥添加到另一台主机上:刚开始第一次传公钥数据需要使用密码来发送;
[root@rhcsa .ssh]# ssh-copy-id root@192.168.188.129
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.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.188.129's password:
# 显示如下信息表示添加成功:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.188.129'"
and check to make sure that only the key(s) you wanted were added.
[root@rhcsa .ssh]#
(3)查看另一台主机是否接收到公钥信息:

#:通过对比可以发现,公钥完全相同,所以129主机所拿到的公钥是正确的,为130所产生的公钥,那么下次登录就可以实现免密登录了:结果如下所示:
[root@rhcsa .ssh]# ssh root@192.168.188.129
Last login: Sun Jul 24 05:42:19 2022 from 192.168.188.1
[root@rhcsa3 ~]#
# :但是这仅限于130主机可以登录129主机,因为130主机所产生的公钥已经传给了129主机,所以在130主机上登录129主机通过秘钥认证就可以成功实现登录,不需要密码,另一台主机的免密登录结果如下:用相同的方法实现另一台主机的公私钥配置发放;
[root@rhcsa .ssh]# ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ss
本文介绍了Linux系统中实现免密登录的步骤,包括生成和传输公钥,以及限制特定用户登录的配置。同时,讲解了HTTP的基本概念,如GET、POST、PUT、DELETE方法,HTTP状态码的分类及其含义,以及HTTP请求报文和响应报文的结构。最后,讨论了HTTP如何通过cookie和session保持连接状态。
最低0.47元/天 解锁文章
&spm=1001.2101.3001.5002&articleId=125961793&d=1&t=3&u=99589d2a7ff24fe6a8c16ea44542d243)
1383

被折叠的 条评论
为什么被折叠?



