2024年4月21日 星期日

Stunnel

Stunnel 有點像 SSH tunnel,可以建立加密通道
原本未加密的協議,讓它走 Stunnel,就可以達到不改變協議,數據有加密的效果
以下用一個實例說明:

A 要 telnet B,IP 12.34.56.78,因 telnet 協議本身未加密,
若要讓 A 到 B 的傳輸數據加密,此時就可以用 Stunnel

建立憑證
cd /etc/stunnel
openssl req -new -x509 -days 9999 -nodes -out stunnel.pem -keyout stunnel.key
把 stunnel.pem 及 stunnel.key copy 到另一台

A 要配置 Stunnel client
/etc/stunnel/stunnel.conf 內容如下
cert = /etc/stunnel/stunnel.pem
key = /etc/stunnel/stunnel.key
client = yes

[telnet]
accept = 23
connect = 12.34.56.78:2323

B 要配置 Stunnel server
/etc/stunnel/stunnel.conf 內容如下
cert = /etc/stunnel/stunnel.pem
key = /etc/stunnel/stunnel.key
client = no

[telnet]
accept = 2323
connect = 127.0.0.1:23

配置後兩邊啟動服務
systemctl enable stunnel --now

在 A 就可以 telnet localhost (取代直連 telnet 12.34.56.78),
然後封包加密,送到 12.34.56.78:2323,
B 收到封包後解密,再送給 localhost:23

沒有留言:

Certificate lifetime reduce to 47 days after 2029-03-15

在 2020年九月,憑證效期縮短為 398 天 爾後最新標準是 47 天,原因一樣是資安考量,分三個階段逐步調整 執行時間表 2026-03-15 縮短成 200 天 2027-03-15 縮短成 100 天 2029-03-15 縮短成 47 天 圖片來源 Sectigo r...