加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

【Linux】免密登录

发布时间:2020-12-14 00:17:01 所属栏目:Linux 来源:网络整理
导读:1.生成密钥 ssh-keygen -t rsa -C "填写自己方便识别的注释" -b 4096 ? 没什么问题就执行三次空格。? 三次问题是1.填入生成密钥对的路径名字。2 填入自定义passphrsa。3确认。? 1 [[email?protected] home]# ssh-keygen -t rsa -C "********" -b 4096 2 Gene

1.生成密钥

ssh-keygen -t rsa -C "<填写自己方便识别的注释>" -b 4096? 没什么问题就执行三次空格。?
三次问题是1.填入生成密钥对的路径名字。2 填入自定义passphrsa。3确认。?

 1 [[email?protected] home]# ssh-keygen -t rsa -C "********" -b 4096
 2 Generating public/private rsa key pair.
 3 Enter file in which to save the key (/root/.ssh/id_rsa): 
 4 Enter passphrase (empty for no passphrase): 
 5 Enter same passphrase again: 
 6 Your identification has been saved in /root/.ssh/id_rsa.
 7 Your public key has been saved in /root/.ssh/id_rsa.pub.
 8 The key fingerprint is:
 9 SHA256:oQYIN3KUkPmnCn0LrC25h5L0yVpiIvoHUgawDuyCKuE **************
10 The key‘s randomart image is:
11 +---[RSA 4096]----+
12 |*==.             |
13 |=*.o             |
14 |o+. .   .        |
15 |= + .. . .       |
16 |+B o  o S        |
17 |*o* ..           |
18 |BEo=..           |
19 |# =+o            |
20 |+*o.             |
21 +----[SHA256]-----+

2.生成的公钥和私钥在/root/.ssh目录下

1 [[email?protected] .ssh]# pwd
2 /root/.ssh
3 [[email?protected] .ssh]# ls -l
4 总用量 12
5 -rw-------. 1 root root 3247 9月  19 10:00 id_rsa       #私钥
6 -rw-r--r--. 1 root root  746 9月  19 10:00 id_rsa.pub   #公钥
7 -rw-r--r--. 1 root root  174 9月  18 16:58 known_hosts

3.将公钥id_rsa.pub复制到远程主机/root/.ssh/文件中,并且重命名为authorized_keys。

  • scp? /root/.ssh/id_rsa.pub? ?[email?protected]远程ip:/root/.ssh/authorized_keys

  • ssh-copy-id? -i? ~/.ssh/id_rsa.pub [email?protected]远程ip

验证密码即可

4.连接

  • ssh?远程ip

5.免确认机器指纹(不加入known_hosts)

  • ssh -o StrictHostKeyChecking=no 远程ip

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读