秘钥管理
Windows
参考: https://learn.microsoft.com/zh-cn/windows-server/administration/openssh/openssh_keymanagement
1 介绍
ssh-keygen,用于生成安全的密钥
ssh-agent 和 ssh-add,用于安全地存储私钥
scp 和 sftp,在首次使用服务器时安全地复制公钥文件
使用power shell
2 启用openssh
# Set the sshd service to be started automatically
Get-Service -Name sshd | Set-Service -StartupType Automatic
# Now start the sshd service
Start-Service sshd
# 由于没有与 sshd 服务关联的用户,因此主机密钥存储在 C:\ProgramData\ssh 下。
# 添加用户秘钥,-t选择加密方式
ssh-keygen -t ed25519
3 秘钥代理
# By default the ssh-agent service is disabled. Allow it to be manually started for the next step to work.
# Make sure you're running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Manual
# Set-Service ssh-agent -StartupType Automatic
# Start the service
Start-Service ssh-agent
# This should return a status of Running
Get-Service ssh-agent
# Now load your key files into ssh-agent
ssh-add ~\.ssh\id_ed25519
4 注册服务
# 注意Get-Service ssh-agent已经注册了这个服务,Set-Service ssh-agent -StartupType Automatic 设置服务自动启动
New-Service -Name ssh-agent -BinaryPathName "C:\Windows\System32\OpenSSH\ssh-agent.exe" -StartupType Automatic
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)