在 Linux 下使用 SecureCRT 配置 SSH 密钥登录,一般分 三步:生成密钥 → 上传公钥到服务器 → SecureCRT 使用私钥连接。下面按最常用、最稳妥的方式说明。
在终端执行:
ssh-keygen -t rsa -b 4096
或(更安全):
ssh-keygen -t ed25519
按提示操作:
~/.ssh/id_rsa生成后会有:
~/.ssh/id_rsa # 私钥
~/.ssh/id_rsa.pub # 公钥
ssh-copy-id user@server_ip
cat ~/.ssh/id_rsa.pub
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "公钥内容" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
如果你在 Windows 上运行 SecureCRT,需要把私钥拷贝到 Windows:
~/.ssh/id_rsa
例如放到:
C:\securecrt\keys\id_rsa
Session → Properties → Connection → SSH2
点击 Properties → Use identity file
选择私钥文件:
C:\securecrt\keys\id_rsa
✅ 如果私钥有 passphrase,连接时会提示输入
原因:
✅ 解决: 在 SecureCRT:
Tools → Convert Private Key to SecureCRT Format
转换 id_rsa 为 .pem 或 .pub
检查:
ls -ld ~/.ssh
ls -l ~/.ssh/authorized_keys
权限必须:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
服务器检查:
grep PubkeyAuthentication /etc/ssh/sshd_config
应为:
PubkeyAuthentication yes
然后重启:
systemctl restart sshd
✅ 安全做法:
ed25519如果你愿意,可以告诉我:
我可以给你 完全对应你环境的配置步骤。