type
status
date
slug
summary
tags
category
icon
password
SSH 配置密钥登录:实现免密码、更安全的登录
生成密钥对
在本地终端或服务器中执行:
- 保存路径:直接回车使用默认路径(
~/.ssh/id_rsa)。
- 密钥密码:可选,若设置则每次使用密钥时需输入;直接回车则不设置。
完成后会生成两个文件:
id_rsa(私钥,保留在本地,务必保密)
id_rsa.pub(公钥,需上传到服务器)
查看公钥内容:
配置服务器
在服务器上执行:
修改 SSH 配置
编辑
/etc/ssh/sshd_config:保存并重启 SSH 服务:
使用密钥登录
如使用 VSCode、MobaXterm 或 PuTTY 等工具,可在连接设置中指定私钥路径。
- Author:KingCode
- URL:https://kingcode.dpdns.org/article/26c41f05-7943-8022-8fe4-c90341bc00d7
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!






