惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog RSS Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
GRAHAM CLULEY
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cybersecurity and Infrastructure Security Agency CISA
Simon Willison's Weblog
Simon Willison's Weblog
Latest news
Latest news
C
CERT Recently Published Vulnerability Notes
T
Threatpost
V
Vulnerabilities – Threatpost
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
C
Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
U
Unit 42
The Register - Security
The Register - Security
T
The Blog of Author Tim Ferriss
Stack Overflow Blog
Stack Overflow Blog
The Hacker News
The Hacker News
AI
AI
Project Zero
Project Zero
Scott Helme
Scott Helme
S
Securelist
Vercel News
Vercel News
GbyAI
GbyAI
S
Security @ Cisco Blogs
I
InfoQ
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
Forbes - Security
Forbes - Security
Google Online Security Blog
Google Online Security Blog
W
WeLiveSecurity
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Heimdal Security Blog
G
Google Developers Blog
D
DataBreaches.Net
The Last Watchdog
The Last Watchdog
D
Docker
MyScale Blog
MyScale Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
T
Tenable Blog
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 聂微东
月光博客
月光博客

博客园 - 曦远Code

给热水器装上“电量显示”:用 Shelly Gen4 脚本实现零改装水量预测 StarBlog番外(5) 从1.6到1.10,基于Avalonia AOT 开发的 Publisher 半年进化之路 你的显卡能跑多少算子?用 55 个检查项,给 PyTorch GPU 环境做一次冒烟测试 ROCm on Windows 性能排查:RX 6650 XT 跑 PyTorch,为什么加速不明显? lighthouse-fw:一个管理腾讯云轻量服务器防火墙的终端工具 用本地大模型驱动中文输入法,我做了一个实验性的项目 Spark.NET:一个试图把 Django / Rails 式开发体验带回 .NET 世界的全栈 Web 框架。 Zed AI 白嫖免费模型,搭配 DeepSeek v4,玩转 Agent 编程技巧 当 CGO 遇见 Zig:一种更优雅的折腾方式,对比 GCC 后端 2026年AI编程工具横评:Cursor、Codex、Claude Code、Zed、Windsurf 后 Django 时代:SQLAlchemy 2.0、Tortoise 与 Piccolo 三大异步 ORM 选型指南 Python网络请求库,从 requests 到 httpx 浅谈次世代代码编辑器 Zed:Rust 原生性能、GPU 渲染 现代 Python 程序优雅处理日期时间的避坑指南 你的SSH密钥可能已经过期了 是谁 2026 年还在用 Sublime Text 写代码? 什么年代了怎么还在用bash啊?现代化shell开箱体验: fish, nu, elvish 2026年的Linux桌面环境选择,哪些适合Debian服务器? 在 Windows 11 上使用 Hyper-V 虚拟机准备安装OpenClaw C# 扩展方法只会写 this 吗?C# 14 新语法直接把扩展方法玩出了花 经历分享,发现挖矿木马后,服务器快速备份与重装(腾讯云平台) Coolify: Vercel 的开源版私有化部署平替版 分享一些2026年有意思的现代化Django生态组件 实测 Django 6.0:模版片段、后台任务、CSP 安全,三大特性体验报告 当人人都能用 AI 写代码时,我为什么选择重回 Django? 打包ROCm环境的相关Wheel方便后续使用 从挖矿木马入侵到 Docker Rootless 加固,我的服务器安全复盘 AMD显卡也能畅玩AI画图!ROCm+ComfyUI部署全指南
别再手动复制SSH公钥了,Linux服务器一键从GitHub快速导入公钥
曦远Code · 2026-03-18 · via 博客园 - 曦远Code

前言

Ubuntu 安装程序(Subiquity)的一大亮点,只要输入 GitHub 用户名,就可以自动导入 SSH 公钥。

它极大地简化了新服务器的初始化配置,让你免去了手动复制粘贴那一大串 SSH Public Key 的烦恼。

原理

GitHub 为每个用户提供了一个公开的 SSH 公钥访问接口。

任何人的公钥都是公开信息的,你只需要在浏览器或终端访问以下 URL 模式: https://github.com/你的用户名.keys

当你输入用户名时,Ubuntu 安装程序在后台执行了类似以下的操作:

  1. 通过网络请求访问 https://github.com/username.keys
  2. 获取该页面返回的纯文本公钥列表。
  3. 将这些公钥追加到服务器对应用户的 ~/.ssh/authorized_keys 文件中。
  4. 确保 .ssh 目录和 authorized_keys 文件的权限正确(通常是 700 和 600)。

如何实现?

方法一:使用 ssh-import-id(最推荐)

Ubuntu 那个功能其实是调用了 ssh-import-id 这个工具,它在 Debian 的官方仓库里也是有的。

  1. 安装工具:

    Bash

    sudo apt update && sudo apt install ssh-import-id -y
    
  2. 导入公钥:

    Bash

    ssh-import-id gh:你的GitHub用户名
    

    注:gh: 前缀代表 GitHub,它也支持 Launchpad(使用 lp:)。

方法二:纯手动万能命令(无需安装任何工具)

如果你不想安装额外的软件包,直接用 curl 配合管道操作也能搞定:

Bash

mkdir -p ~/.ssh && chmod 700 ~/.ssh
curl -L https://github.com/你的用户名.keys >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Tips

  • 这种方式依赖于 GitHub 的可用性和网络连接。如果你在公司内网或者特殊网络环境下,记得确认服务器能否正常访问 github.com
  • 多平台支持: 除了 GitHub,GitLab 也提供类似的功能,链接格式为 https://gitlab.com/用户名.keys
  • 自动化部署: 如果你经常折腾服务器,可以把上面那行 curl 命令写进你的初始化脚本或 Dockerfile 中,实现真正的“无感”配置。

微信公众号:「程序设计实验室」 专注于互联网热门新技术探索与团队敏捷开发实践,包括架构设计、机器学习与数据分析算法、移动端开发、Linux、Web前后端开发等,欢迎一起探讨技术,分享学习实践经验。