SSH Tunneling
Linux SSH Tunnel 設定步驟
在這部分,我們將探討如何在Linux系統中設定SSH Tunnel。SSH Tunnel是一種通過加密的SSH協議來傳輸資料的方法,能有效保護資料免受中間人攻擊,以及測試網路流量。
What is SSH Tunneling
SSH Tunneling is a method of creating an encrypted SSH connection between a client and a server machine through which services ports can be relayed, for example:

Pre-requisites
- Rocky Linux VM x 2
- Install Grafana on one of them
| vm | ip | service port |
|---|---|---|
| VM I (SSH Client) | 10.250.75.103 | |
| VM II (SSH Server) | 10.250.75.147 | 3000 (Grafana) |
- 確保
/etc/ssh/sshd_config內的AllowTcpForwarding為yes
Get Started
使用 ssh command 在 VM I:
-N : Do not execute a remote command.
-L : Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the remote side.
0.0.0.0:8080:127.0.0.1:3000 :
Client Server上「所有 (0.0.0.0)」網絡介面上的8080端口的流量轉發到Remote Server的127.0.0.1:3000。root@10.250.75.147
ssh server的位置
ssh -N -L 0.0.0.0:8080:127.0.0.1:3000 root@10.250.75.147
成功透過 10.250.75.103:8080 訪問 10.250.75.147:3000:
