SSH安全加固

  • 隱藏SSH登錄的bannner   默認爲空

  • 修改ssh的版本信息

  • # cp /usr/sbin/sshd /usr/sbin/sshd.bak

    # strings /usr/sbin/sshd | grep 6.6

    # sed -i 's/OpenSSH_6.6/OpenSSH_8.8/g' /usr/sbin/sshd

    # service restart sshd

  • SSH使用版本2

 # Protocol = 2

  • 不允許root遠程登錄;

 # PermitRootLogin no #禁止root登錄SSH

  • 不允許空密碼

  • 不允許rlogin、rhost登錄

 # IgnoreRhosts =yes;

  • 配置並限制允許登錄的IP地址與賬戶

 # cat /etc/ssh/sshd_config顯示控制可訪問的IP和賬戶

   AllowUsersuser1 user2

 或#more /etc/hosts.allow 

   sshd:10.0.0.1:allow

  • 更改默認監聽端口,設置非標準端口

  • 密碼重試次數

MaxAuthTries=6
   Configure Idle Log Out Timeout Interval
   ClientAliveInterval 300
   ClientAliveCountMax 0
   設定空閒會話超時時長;

  • Firewall SSH Port # 22
       使用iptables設置ssh服務安全訪問策略

  • Use Log Analyzer
       記錄好日誌,經常做日誌分析

  • 禁用ssh弱加密

# vim /etc/ssh/sshd_config

Ciphers aes192-ctr,aes256-ctr,arcfour256

MACs hmac-sha1,hmac-ripemd160

#查看命令

ssh -vv -oCiphers=aes128-cbc,3des-cbc,blowfish-cbc <serverIP>

#驗證:ssh -vv -o Ciphers=aes192-ctr,aes256-ctr serverIP

會提示passwd登錄證明已經匹配

 


 ssh服務的最佳實踐:
  1、不要使用默認端口;
  2、禁止使用protocol version 1;
  3、限制可登錄用戶;
  4、設定空閒會話超時時長;
  5、利用防火牆設置ssh訪問策略;
  6、僅監聽特定的IP地址;
  7、基於口令認證時,使用強密碼策略;
  8、使用基於密鑰的認證;
  9、禁止使用空密碼;
  10、禁止root用戶直接登錄;
  11、限制ssh的訪問頻度和併發在線數;
  12、做好日誌,經常分析;
 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章