Panchant's Blog!

Home
Blog
  • Archive
  • Cats.
  • Tags
Mine
  • Friends
About
Search
0

Linux 密钥登录

Published on 7/19/2026
Updated on 7/19/2026
教程
Estimated reading 0.7 minutes
357 words

Linux 密钥登录

本文记录如何用 SSH 密钥登录远程服务器,避免每次都输入密码。

1. 在本地生成 SSH 密钥

Linux、macOS、Windows PowerShell 都可以运行:

bash
ssh-keygen -t ed25519 -C "Panchant@stu.xjtu.edu.cn"
ssh-keygen -t ed25519 -C "Panchant@stu.xjtu.edu.cn"

一路按回车即可。默认生成:

text
~/.ssh/id_ed25519       # 私钥,不能泄露
~/.ssh/id_ed25519.pub   # 公钥,可以放到服务器
~/.ssh/id_ed25519       # 私钥,不能泄露
~/.ssh/id_ed25519.pub   # 公钥,可以放到服务器

2. 把公钥复制到远程服务器

bash
ssh-copy-id 用户名@服务器IP
ssh-copy-id 用户名@服务器IP

例如:

bash
ssh-copy-id ubuntu@192.168.1.100
ssh-copy-id ubuntu@192.168.1.100

这一步最后还需要输入一次服务器密码。

之后连接:

bash
ssh ubuntu@192.168.1.100
ssh ubuntu@192.168.1.100

就不再要求服务器密码了。

Related Post
Comments
author-avatar
Panchant
A student, and a runner.
29
Arts.
12
Cats.
58
Tags
Customed
This is the custom content section
Anything can be placed here
TOC
  1. Linux 密钥登录
  2. 1. 在本地生成 SSH 密钥
  3. 2. 把公钥复制到远程服务器
© 2025-2026 By Panchant
由 Astro v2.8.3 构建 | 主题 HsuBlog
Build with by Panchant
Search
Extended SearchHelloWorld
You can use a unix-like format: Extended Search