前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >linux配置免密登陆

linux配置免密登陆

原创
作者头像
用户14527
发布2022-08-16 17:39:18
5.2K0
发布2022-08-16 17:39:18
举报
文章被收录于专栏:supreme
代码语言:javascript
复制
[root@VM-11-6-centos .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
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:z8OjvmpTfFsSN1+CIpMun3BvDE/YgO/ZoVU0g+j0wjk root@VM-11-6-centos
The key's randomart image is:
+---[RSA 2048]----+
|         . .     |
|        o . +    |
|       = + . +   |
|      . E + = . .|
|       +SO = o o |
|      o O+B . .  |
|       B &*=     |
|      o *.Bo     |
|     ..++o       |
+----[SHA256]-----+
[root@VM-11-6-centos .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub

id_rsa.pub公钥传至authorized_keys或者手动复制

[root@VM-11-6-centos .ssh]# chmod 600 authorized_keys
[root@VM-11-6-centos ~]# chmod 700 .ssh/
[root@VM-11-6-centos .ssh]# scp id_rsa id_rsa.pub root@172.16.11.16:/root/.ssh/
The authenticity of host '172.16.11.16 (172.16.11.16)' can't be established.
ECDSA key fingerprint is SHA256:WKCT+eDW17GPtADwTCIxTnEssoynlYB/eIUly1D0y9w.
ECDSA key fingerprint is MD5:fd:16:cd:5a:d3:e9:bc:2b:67:27:97:aa:66:93:a5:33.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.11.16' (ECDSA) to the list of known hosts.
root@172.16.11.16's password: 
id_rsa                                       100% 1675     5.3MB/s   00:00    
id_rsa.pub                                   100%  401     1.6MB/s   00:00
[root@VM-11-6-centos .ssh]# exit
logout
Connection to 172.16.11.6 closed.
[root@VM-11-16-centos ~]# cd .
./       ../      .cache/  .config/ .pip/    .ssh/    
[root@VM-11-16-centos ~]# cd .ssh/
[root@VM-11-16-centos .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@VM-11-16-centos .ssh]# ssh root@172.16.11.6
Last login: Tue Aug 16 17:26:28 2022 from 172.16.11.16
[root@VM-11-6-centos ~]# ^C

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档