在 Ubuntu 上使用 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
vi ~/.ssh/authorized_keys
# 粘贴公钥
chmod 600 ~/.ssh/authorized_keys
SecureCRT 不能直接用 OpenSSH 的私钥,需要转换:
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
然后用 SecureCRT 自带的工具:
Tools → Convert Private Key to SecureCRT Format~/.ssh/id_rsa.ini 或 .pemFile → Connect → New Sessionauthorized_keys服务器上:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
服务器 /etc/ssh/sshd_config:
PasswordAuthentication no
重启:
sudo systemctl restart ssh
如果你是用 SecureCRT for Linux 还是 Windows 连 Ubuntu 服务器,可以告诉我,我可以给你更精确的步骤。