在 Linux 下使用 SecureCRT 配置 SSH 密钥登录,一般流程如下(以 RSA 密钥为例,其他算法类似):
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
按提示操作:
~/.ssh/id_rsa生成后会有两个文件:
~/.ssh/id_rsa # 私钥(本地保存)
~/.ssh/id_rsa.pub # 公钥(传到服务器)
ssh-copy-id user@server_ip
cat ~/.ssh/id_rsa.pub | ssh user@server_ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
并设置权限:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
SSH2进入:
Session Options → SSH2 → Authentication
勾选并调整顺序:
✅ PublicKey
❌ Password(或放到后面)
点击 Properties(或 PublicKey 设置):
~/.ssh/id_rsa
⚠️ SecureCRT 不能直接使用 OpenSSH 私钥格式(新版)
如果报错,需要转换格式(见下方)
head -n 1 ~/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
-----BEGIN OPENSSH PRIVATE KEY-----
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
然后重新在 SecureCRT 中选择该私钥即可。
编辑:
sudo vi /etc/ssh/sshd_config
确保开启:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重启 SSH:
sudo systemctl restart sshd
ssh user@server_ip
如果无需输入密码即可登录,说明密钥配置成功 ✅
| 问题 | 原因 |
|---|---|
| SecureCRT 提示“No supported authentication methods” | 公钥未生效 / 私钥格式错误 |
| 仍然要求输入密码 | authorized_keys 权限不对 |
| 无法加载私钥 | SecureCRT 不支持 OpenSSH 新格式 |
如果你愿意,可以告诉我:
我可以帮你 精确对应版本一步步配置。