- ADDR=控制用機器的公開IP address
- USER=控制用機器上面的帳號
事先在遠端的機器開啟終端機輸入:
- ssh -fNR 55555:localhost:22 ${USER}@${ADDR}
- ssh localhost -p 55555
====================== 這是有沒有視窗的分割線 ======================
若要將遠端機器的視窗接過來看,需開啟SSH通道的X forwarding,故遠端的機器指令:
- ssh -XfNR 55555:localhost:22 ${USER}@${ADDR}
- ssh localhost -Xp 55555
====================== 這是參數介紹的分隔線 ======================
- -f:要求ssh丟到背景裡面執行
- -N:不要執行遠端的指令,對於forwarding ports有用
- -R:port:host:hostport
Specifies that connections to the given TCP port on the remote (server) host are to be forwarded to the given host and port on the local side. This works by allocating a socket to listen to a TCP port on the remote side. Whenever a connection is made to this port, the connection is forwarded over the secure channel, and a connection is made to the host port hostport from the local machine. - -X:開啟X11 forwarding
- -p:連線使用的port
參考資料
- Reverse SSH Tunnel 反向打洞實錄
- Reverse X11 forwarding
- 鑿一個反向 ssh 隧道, 對朋友或世界展示筆電或家裡的某個服務
- SSH遠端連線,接視窗回本機使用:上述的招式搭配這招,就可以透過控制用的機器,把遠端機器的視窗接到本機上面來用~
- 看port被佔用的情形
- 將sshd開在許多個port上面
- How to configure SSH port forwarding and set up load testing on Compute Engine:裡面解釋了client-side port forwarding與server-side port forwarding的不同
沒有留言:
張貼留言