首页 > 硬件测评 > 正文内容

ssh免密登录的两种方式

时间:2024-05-04 04:00:39

内容一:

一、ssh远程登录操作。这里先看看正常使用ssh连接其他服务器的操作。准备了两台服务器ip分别为:192.168.150.175、192.168.150.148。这里使用175登录148。

二、ssh免密登录方式一。其实很简单,只需要三步即可:

三、ssh免密登录方式二。认真看过第二种方式就会知道,第二种方式必须要知道服务器的密码,而且还是root密码,这个在工作中可能有点难度,所以我们真正使用这个方式比较靠谱吧。

内容二:

1. 使用ssh-keygen生成私钥公钥对,一直输入回车即可

2. 查看生成的公钥,cat/root/.ssh/id_rsa.pub目的是验证该文件是否存在和格式是否正确一般后面会把主机名带上,检查好格式

3. 将公钥推送到远端服务器上ssh-copy-id-i~/.ssh/id_rsa.pub192.168.10.211第一次需要验证密码

内容三:

1. 假设有两台服务器server(192.168.16.10)和client(192.168.16.11),现在需要client可以免密登陆server.

2. 在服务器client上创建密钥(命令运行中一路回车即可)[root@client~]#ssh-keygen-trsaGeneratingpublic/privatersakeypair.Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):Enterpassphrase(emptyfornopassphrase):Entersamepassphraseagain:Youridentificationhasbeensavedin/root/.ssh/id_rsa.Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.Thekeyfingerprintis:b7:01:7d:f7:51:73:c4:f2:3c:6c:61:fa:ae:f9:d6:earoot@clientThekey'srandomartimageis:+--[RSA2048]----+|++||..o=||...==.||..o=+||Sooo||.o.||...||.o.||+Eo|+-----------------+

3. 在服务器server上加入密钥(过程中选yes并输入client的密码一次)[root@server~]#sshclientcat~/.ssh/id_rsa.pub>>~/.ssh/authorized_keysTheauthenticityofhost'client(192.168.16.11)'can'tbeestablished.RSAkeyfingerprintis8d:88:19:2d:a9:15:e1:f6:3e:c9:0e:48:53:cf:8c:f7.Areyousureyouwanttocontinueconnecting(yes/no)?yesWarning:Permanentlyadded'client'(RSA)tothelistofknownhosts.root@client'spassword:

版权声明:转载此文是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益, 请作者持权属证明与本网联系,我们将及时更正、删除,谢谢您的支持与理解。
标签:硬件测评

快测评广州东远堂信息科技有限公司版权所有 量子科技网提供支持 粤ICP备15011623号