SFTP加密配置主要涉及SSH協議相關參數,以下是關鍵選項及建議:
加密算法選擇
aes256-gcm@openssh.com
、aes128-gcm@openssh.com
)或AES-CTR(如aes256-ctr
、aes128-ctr
),安全性高且性能較好。配置文件參數
sshd_config
:在/etc/ssh/sshd_config
中添加或修改以下選項:# 指定加密算法(多個算法用逗號分隔)
Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes128-ctr
# 密鑰交換算法(可選,默認已較安全)
KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group14-sha256
# 消息認證碼(MAC)算法
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com
其他安全增強
X11Forwarding no
、AllowTcpForwarding no
,減少攻擊面。PasswordAuthentication no
)。驗證與重啟
sudo systemctl restart sshd
。sftp -v
命令測試連接,確認輸出中包含加密算法信息(如debug1: kex: algorithm: curve25519-sha256@libssh.org
)。注意:具體配置需根據服務器系統(Linux/Windows)和SSH版本調整,優先參考官方文檔。