温馨提示×

Debian中SecureCRT如何配密钥

小樊
46
2026-09-13 22:55:53
栏目: 智能运维

在 Debian(作为 SSH 服务端) 上使用 SecureCRT(客户端) 配置 密钥登录(公钥认证),一般步骤如下:


一、在 SecureCRT 中生成密钥

  1. 打开 SecureCRT
  2. 菜单:Tools → Create Public Key
  3. 选择密钥类型:
    • 推荐 RSA,长度 2048 或 4096
  4. 设置 Passphrase(密钥密码,可留空)
  5. 生成后保存两个文件:
    • 私钥:Identity 或 xxx.pub 对应私钥
    • 公钥:xxx.pub

SecureCRT 默认生成的是 OpenSSH 格式或 SecureCRT 格式 Debian 一般用 OpenSSH 格式


二、将公钥上传到 Debian 服务器

1. 登录 Debian(密码方式)

ssh user@debian_ip

2. 创建 .ssh 目录(如果不存在)

mkdir -p ~/.ssh
chmod 700 ~/.ssh

3. 添加公钥

将 SecureCRT 生成的 .pub 文件内容粘贴到:

nano ~/.ssh/authorized_keys

或上传后:

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

4. 设置权限(非常重要)

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

三、在 SecureCRT 中配置使用密钥

  1. 新建或编辑 Session
  2. Connection → SSH2
  3. Authentication:
    • 勾选 PublicKey
    • 取消 Password(可选)
  4. Properties → 选择私钥文件(Identity 或 .pub 对应的私钥)
  5. 如有 Passphrase,输入密钥密码

四、Debian 服务端 SSH 配置(确认)

编辑:

sudo nano /etc/ssh/sshd_config

确保以下配置:

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no   # 可选,禁用密码

重启 SSH:

sudo systemctl restart ssh

五、常见问题排查

1. 无法登录

sudo tail -f /var/log/auth.log

2. 权限错误(最常见)

  • .ssh 不能是 777
  • authorized_keys 不能是 664

3. SecureCRT 公钥格式不对

  • 用 SecureCRT 导出为 OpenSSH format

六、示例(推荐结构)

~/.ssh/
├── authorized_keys
└── (server side only)

如果你愿意,我可以:

  • 给你 SecureCRT 具体截图级步骤
  • 或帮你 转换 SecureCRT 密钥为 Linux 格式
  • 或配置 只允许密钥登录的安全方案

告诉我你的 SecureCRT 版本和 Debian 版本即可。

0 踩