在 Debian 上使用 SecureCRT 进行密钥(SSH Key)认证,一般分为 生成密钥 和 配置 SecureCRT 连接 两部分。下面按最常见、最安全的方式一步一步说明(适用于 SecureCRT 9.x / 8.x)。
先确认 SSH 服务已启用:
sudo systemctl status ssh
如果未启动:
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
Tools(工具) → Create Public Key...
按向导操作:
Key Type(密钥类型)
✅ 推荐:RSA 或 ED25519
Passphrase(私钥密码)
建议设置(防止私钥被拷走滥用)
Key Format(密钥格式)
✅ 选择 OpenSSH
❌ 不要用 SecureCRT 专有格式(不方便服务器使用)
保存路径
id_rsa / id_ed25519id_rsa.pubssh user@debian_ip
.ssh 目录(如果不存在)mkdir -p ~/.ssh
chmod 700 ~/.ssh
.pub 内容写入 authorized_keysnano ~/.ssh/authorized_keys
粘贴公钥内容(一行)
chmod 600 ~/.ssh/authorized_keys
Session Options → SSH2
PublicKey → Properties → Use session public key
选择刚才生成的 私钥文件
编辑 SSH 配置:
sudo nano /etc/ssh/sshd_config
确保以下配置存在且未被注释:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
(可选)禁用密码登录:
PasswordAuthentication no
重启 SSH:
sudo systemctl restart ssh
检查:
ls -ld ~/.ssh
ls -l ~/.ssh/authorized_keys
权限必须是:
.ssh → 700
authorized_keys → 600
Debian 默认可能禁止 root 登录:
PermitRootLogin prohibit-password
| 项目 | 推荐 |
|---|---|
| 密钥类型 | ED25519 |
| 私钥密码 | 设置 |
| SSH 端口 | 非 22 |
| 登录方式 | 仅密钥 |
| 防火墙 | ufw / iptables |
如果你愿意,可以告诉我:
我可以直接给你 针对你环境的精确配置命令。