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

沒有留言:

Eazy way to install OpenWrt

這個方法網路要通,直接抓 image 寫入硬碟 隨便找一片 Linux ISO 開到 rescue 模式 fdisk -l 看一下硬碟位置,如果是 /dev/sda curl https://repo.jing.rocks/openwrt/releases/23.05.3/tar...