Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

SecureCRT 配置 SSH Key 登入 Linux 的步驟

使用 SSH 公鑰登入 Linux 可提升安全性並免除密碼輸入。本文以 SecureCRT 為例,說明如何產生密鑰、上傳公鑰、修改 sshd 設定並完成登入。

一、產生公鑰與私鑰

在 SecureCRT 中選擇:

工具 → 建立公鑰

加密演算法可選 RSA。系統會產生 Identity 與 Identity.pub 兩個檔案,其中 Identity 是私鑰,Identity.pub 是公鑰。通行短語可留空;若設定,登入時會要求輸入。

二、上傳公鑰並設定權限

在目標使用者目錄建立 .ssh:

mkdir .ssh

chmod 755 .ssh

將公鑰轉換並附加到 authorized_keys:

ssh-keygen -i -f .ssh/Identity.pub >> .ssh/authorized_keys

chmod 644 .ssh/authorized_keys

上傳公鑰時建議使用 ASCII 格式,避免換行或編碼造成驗證失敗。

三、修改 sshd 設定

編輯:

vim /etc/ssh/sshd_config

確認或加入:

Protocol 2

Port 22

PermitRootLogin yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

RSAAuthentication yes

PasswordAuthentication no

若停用密碼登入,可避免暴力破解,但管理者需先確認公鑰登入正常,再關閉密碼驗證。

四、重啟 SSH 服務

/etc/init.d/ssh restart

完成後,即可使用 SecureCRT 指定私鑰登入目標主機。

Copyright © Linux教程網 All Rights Reserved