温馨提示×

linux securecrt如何配置密钥

小樊
47
2026-09-09 16:30:57
栏目: 智能运维

在 Linux 下使用 SecureCRT 配置 密钥登录(SSH Key 认证),通常分为两部分:

  1. 在 Linux 上生成密钥对
  2. 在 SecureCRT 中导入/使用私钥并配置会话

下面按步骤说明(以常见的 RSA / ED25519 为例)。


一、在 Linux 上生成密钥(如果还没有)

1. 生成密钥

ssh-keygen -t rsa -b 4096
# 或(推荐)
ssh-keygen -t ed25519
  • 默认生成位置:
    • 私钥:~/.ssh/id_rsa
    • 公钥:~/.ssh/id_rsa.pub
  • 可设置密码(passphrase),更安全

2. 将公钥传到服务器

ssh-copy-id user@server_ip

或手动追加到服务器:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

二、SecureCRT 中使用密钥(两种方式)

✅ 方式一:直接使用 Linux 生成的 OpenSSH 私钥(推荐)

SecureCRT(较新版本)支持 OpenSSH 格式私钥。

  1. 打开 SecureCRT
  2. 新建或编辑 Session
  3. 进入:
    Connection → SSH2
    
  4. Authentication 中选择:
    • ✅ PublicKey
  5. 点击 Properties
  6. 选择:
    • Use identity file
  7. 浏览并选择:
    /home/youruser/.ssh/id_rsa
    
  8. 如果生成时设置了 passphrase,连接时会提示输入

✅ 无需转换格式,最简单


✅ 方式二:使用 SecureCRT 自己的密钥格式

如果你不想用 OpenSSH 密钥:

1. 在 SecureCRT 生成密钥

Tools → Create Public Key
  • Key type: RSA / DSA / ECDSA
  • 设置 passphrase
  • 保存为 .pub 和私钥

2. 上传公钥到服务器

SecureCRT 生成的 .pub 是 RFC4716 格式,需要转换:

ssh-keygen -i -f securecrt.pub >> ~/.ssh/authorized_keys

三、服务器端必要配置

确保 /etc/ssh/sshd_config 中:

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

修改后重启:

systemctl restart sshd

四、常见问题

1. 权限错误

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/id_rsa

2. SecureCRT 连不上

  • 确认 Authentication 顺序中 PublicKey 在前
  • 确认防火墙 / SELinux
  • 查看服务器日志:
    tail -f /var/log/secure
    

五、总结

最简单方案

Linux 生成 OpenSSH 密钥 → SecureCRT 直接选私钥文件

如果你愿意,可以告诉我:

  • SecureCRT 版本
  • Linux 发行版
  • 是否用跳板机

我可以给你更精确的配置示例。

0