ssh-keygen -t rsa # 連按三次 Enter (或設定密鑰密碼) # 產生 ~/.ssh/id_rsa (私鑰) 與 id_rsa.pub (公鑰)
工具 → 使用者金鑰產生精靈 → 選 RSA/2048 → 設定密碼 → 另存公鑰為 id_rsa.pub。
# 上傳 id_rsa.pub 至 ~/.ssh/authorized_keys mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys chmod 700 ~/.ssh
vi /etc/ssh/sshd_config RSAAuthentication yes PubkeyAuthentication yes # 重啟 sshd /etc/init.d/ssh restart # Debian/Ubuntu /etc/init.d/sshd restart # CentOS
id_rsa 轉存為 .ppk,Session 設定 Connection → SSH → Auth 選擇私鑰檔。chmod 600 id_rsa; ssh -i id_rsa user@host。vi /etc/ssh/sshd_config PasswordAuthentication no # 重啟 sshd
重要:妥善備份私鑰 (id_rsa 或 .ppk),遺失將無法登入。