更新 CentOS 账号秘钥
- 通过子账号登入系统
- 创建密钥对
[username@devicename ~]$ ssh-keygen -t rsa -C "20230912" # -C参数为备注,方便自己辨识
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): # 回车,默认路径
Created directory '/home/username/.ssh'.
Enter passphrase (empty for no passphrase): # 回车,默认空密码
Enter same passphrase again: # 回车,默认空密码
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
- 打开新生成的
id_rsa.pub
公钥,复制里面的内容 - 在新密钥文件的相同目录下找到 authorized_keys 文件,将公钥内容全部覆盖到该文件内
- 下载新生成的
id_rsa
私钥,此私钥可用于远程 SSH 登录(注意要开放登录端口)
本文来自作者:西湖摸鱼,转载请注明原文链接:https://www.cnblogs.com/conne/p/17696178.html