LINUX
SSH 连接配置:双服务器免密登录
配置 WSL 到腾讯云 CVM 与宿舍 M920q 的 SSH 密钥认证,含 scp/sftp 文件传输备忘。
SSH 配置文件
WSL 中的 ~/.ssh/config(完整内容):
Host TencentCloud
HostName 118.89.113.212
User root
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 60
ServerAliveCountMax 3
Host m920q
HostName 192.168.5.2
User snow
IdentityFile ~/.ssh/id_ed25519
ServerAliveInterval 60
两台服务器共用同一把 id_ed25519 密钥。使用时只需:
ssh TencentCloud # 云服务器
ssh m920q # 宿舍服务器
密钥配置(已完成)
生成密钥:
ssh-keygen -t ed25519 -C "tencent-cloud"
复制公钥到两台服务器(各需输入一次密码):
ssh-copy-id -i ~/.ssh/id_ed25519.pub TencentCloud
ssh-copy-id -i ~/.ssh/id_ed25519.pub m920q
主机密钥变更处理
重装系统后出现 REMOTE HOST IDENTIFICATION HAS CHANGED 是正常现象:
ssh-keygen -f ~/.ssh/known_hosts -R 118.89.113.212
重装记录
| 日期 | 操作 |
|---|---|
| 2026-07-12 | 初装:OpenCloudOS 9.6 + 宝塔面板 |
| 2026-07-12 | 重装:Debian 13 (trixie) 裸机 |
| 2026-07-13 | 清除旧主机指纹 + ssh-copy-id 配置免密 |
快速验证
ssh TencentCloud 'hostname'
ssh m920q 'hostname'
SCP 文件传输备忘
# 上传到云服务器
scp localfile.txt TencentCloud:/root/
# 从云服务器下载
scp TencentCloud:/root/data.txt .
# 上传到宿舍服务器
scp localfile.txt m920q:/home/snow/