如何解決 SSH Server 使用了不安全的加密演算法: ARCFOUR、CBC、HMAC-MD5、HMAC-RIPEMD160

弱點掃瞄

弱點 1: SSH Supports Weak Cipher

The SSH server is configured to support either Arcfour or Cipher Block Chaining (CBC) mode cipher algorithms. SSH can be configured to use Counter (CTR) mode encryption instead of CBC. The use of Arcfour algorithms should be disabled.

  • Severity: Medium
  • Risk: A weak cipher has been detected.
  • Recommendation: Configure the SSH server to disable Arcfour and CBC ciphers.

弱點 2: SSH Supports Weak MAC

The SSH server is configured to support MD5 algorithm. The cryptographic strength depends upon the size of the key and algorithm that is used. A Modern MAC algorithms such as SHA1 or SHA2 should be used instead.

  • Severity: Medium
  • Risk: A weak Message Authentication Code (MAC) algorithm has been detected.
  • Recommendation: Configure the SSH server to disable the use of MD5.

繼續閱讀

用 Fail2Ban 防範暴力破解 (SSH、vsftp、dovecot、sendmail)

Fail2Ban 可以用來防護 Linux Server 上的 SSH、vsftp、dovecot...等服務免於遭駭客使用暴力密碼入侵。我以前曾寫過即時封鎖想要入侵 SSH 的程式,不過 Fail2Ban 厲害多了,也完全可以取代我寫的程式。

安裝 Fail2Ban

安裝前可以先用下列指令來查看可安裝的版本:

yum info fail2ban

像我的系統 (CentOS 5.x) 查出來有兩個版本: 0.8.14 與 0.6.0,來自不同的套件庫,但預設卻安裝 0.6.0,所以我必須要指定安裝的版本為 0.8.14,以下的說明也是針對 0.8.*

安裝 Fail2Ban:

yum install fail2ban

yum install fail2ban-版本

啟動 Fail2Ban:

service fail2ban start
chkconfig fail2ban on

繼續閱讀

增加 ssh 的安全性設定

編輯 /etc/ssh/sshd_config,加入或修改下列參數:

#禁止 root 以 SSH 登入
PermitRootLogin no

#僅允許特定群組登入
AllowGroups group1 group2

#僅允許特定帳號登入
#(注意,AllowUsers 會覆寫 AllowGroups,若你有群組登入的需求,就不能設 AllowUsers)
AllowUsers user1 user2

#禁止使用空白密碼登入
PermitEmptyPasswords no

#限定只能使用 SSH2 協定
Protocol 2

#限定最多可以同時連線的數目
MaxStartups 5

在 Windows 使用「非對稱金鑰」來遠端登入 SSH 的方法

在 Linux Server 下使用 SSH 的「非對稱金鑰」來進行遠端登入的方式相信大家應該都不陌生 (沒實做過的可參考鳥哥或 study-area 的文件),下面我所要介紹的是在 Windows 下使用金鑰來遠端登入 SSH 的方法。

開始之前,先說一下「非對稱金鑰」:

「非對稱金鑰」是一種加密機制,由用戶端以特定的加密演算法產生兩把「非對稱」金鑰: 即「公鑰 (Public-Key)」與「私鑰 (Private-Key)」。然後我們會把「私鑰」留在自己的電腦,再把「公鑰」傳送到遠端主機,當兩把金鑰碰在一起就會進行加解密比對,以確認是否彼此的身份是可以信任的,藉以執行特定的作業。

說得更簡單一點,與其說是「公鑰」與「私鑰」,不如說是「鎖頭」與「鑰匙」,由我自己來打造一組鎖頭及鑰匙,我把這個鎖頭裝在一個門上,然後我就可以用我的這一把鑰匙來打開這扇門了! 同時呢,我也可以把相同的鎖頭裝在很多的門上,那我就可以用這一把鑰匙來開啟很多門了…這樣子的概念是否有比較清楚了呢?!

繼續閱讀