天天看點

SSH安全配置

     配置基于CentOS7

配置檔案: 

  /etc/ssh/sshd_config

設定檔案權限

chown root:root /etc/ssh/sshd_config
chmod og-rwx /etc/ssh/sshd_config      

配置檔案

####   這裡設定了禁止root登入,請確定一定提前建立好登入使用者

# 設定日志級别
LogLevel INFO
# 使用者登入失敗,在切斷連接配接前伺服器需要等待的時間,機關為秒
LoginGraceTime 60
# 不允許root登入
PermitRootLogin no
# 密碼驗證失敗允許次數
MaxAuthTries 4
# 這是通過在RSA認證成功後再檢查 ~/.rhosts 或 /etc/hosts.equiv 進行認證的。出于安全考慮,建議使用預設值"no"。
HostbasedAuthentication no
# 是否在 RhostsRSAAuthentication 或 HostbasedAuthentication 過程中忽略 .rhosts 和 .shosts 檔案。
不過 /etc/hosts.equiv 和 /etc/shosts.equiv 仍将被使用。推薦設為預設值"yes"。
IgnoreRhosts yes
# 不允許空密碼登入
PermitEmptyPasswords no
# 禁止下x11轉發
X11Forwarding no
# 指定是否允許 sshd(8) 處理 ~/.ssh/environment 以及 ~/.ssh/authorized_keys 中的 environment= 選項。
預設值是"no"。如果設為"yes"可能會導緻使用者有機會使用某些機制(比如LD_PRELOAD)繞過通路控制,造成安全漏洞
PermitUserEnvironment no
# ssh會話存活時間
ClientAliveInterval 300
# 到達會話存活時間,發送alive給伺服器的次數
ClientAliveCountMax 0
# 使用ssh協定2
Protocol 2
# 隻使用經準許的MAC算法
MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]
# 允許的使用者通過ssh登入
AllowUsers  redhat
# 允許的組通過ssh登入
AllowGroups root redhat
# 使用者登陸前的提示資訊檔案路徑
Banner /etc/issue.net
      

繼續閱讀