在 Linux 下使用 SecureCRT 通过密钥(SSH Key)登录服务器,一般分为 生成密钥 → 上传公钥 → 配置 SecureCRT → 服务器端设置 这几个步骤。下面按常见场景详细说明。
在本地 Linux 终端执行:
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
自动将公钥写入服务器:
~/.ssh/authorized_keys
scp ~/.ssh/id_rsa.pub user@server_ip:/tmp/
登录服务器后:
mkdir -p ~/.ssh
cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
编辑服务器 SSH 配置:
sudo vi /etc/ssh/sshd_config
确保以下配置存在且未被注释:
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重启 SSH 服务:
sudo systemctl restart sshd
File → Connect → New Session~/.ssh/id_rsa
(SecureCRT 支持 OpenSSH 格式)✅ 如果私钥有 passphrase,会提示输入
Tools → Create Public Keyid_secrtid_secrt.pubcat id_secrt.pub >> ~/.ssh/authorized_keys
⚠️ 注意:SecureCRT 生成的公钥格式与 OpenSSH 略有不同,需确认服务器支持。
✅ 检查:
PubkeyAuthenticationchmod 600 ~/.ssh/id_rsa
ssh -vvv user@server_ip
✅ 检查:
authorized_keys 权限restorecon -Rv ~/.ssh
PasswordAuthentication no
Linux 生成密钥
↓
上传公钥到服务器
↓
服务器开启公钥认证
↓
SecureCRT 指定私钥登录
如果你愿意,可以告诉我:
我可以给你 更精确的配置示例。