2022年12月17日 星期六

Telnet to a node's console on remote GNS server through SSH tunnel

Connect a node on remote GNS3 server through SSH tunnel

A dstnat is required to forward node_dstnat_port to node_console_port on GNS3 

For telnet
ssh -Nf -L local_port:gns3_server_ip:node_dstnat_port ssh_user@ssh_server
telnet localhost:local_port

User PuTTY to connect a node on remote GNS3 server through SSH tunnel


PuTTY --> SSH server --> GNS3 remote server 

(1) Command line:

C:\>putty username@proxy-ssh-server -L localport:gns3-remote-server:node-console-port

C:\>telnet localhost localport


(2) GUI
Open PuTTY 

-> Session 

Host Name: remote-server-name Port: remote-node-port

->Connection -> Proxy

Proxy type: Local

Proxy hostname: hostname-for-ssh-server

Port: 22

Username: username-for-ssh-server

Password: password-for-ssh-server

local proxy command:

plink -pw %pass %user@%proxyhost -nc %host:%port

-> Session

Saved sessions: name-for-node

click save


更新 .ssh/config 內容如下之後:


1. 如果要連接 vm3,則輸入

ssh vm3 

輸入 pc106 和 vm3 的 password 就可以連線。


2. 如果要從 vm3 下載或上傳資料,則輸入

ssh -Nf pc106

之後,如要複製 $HOME/history 檔案,則可輸入

scp -P 3199 127.0.0.1:history history

就會把檔案從 vm3 下載到本機,要留意的是遠端檔案的正確路徑和名稱。


Host *

        StrictHostKeyChecking no

        Ciphers aes256-gcm@openssh.com

Host pc106

        HostName 120.125.80.106

        LocalForward 3197 163.28.10.197:22

        LocalForward 3198 163.28.10.198:22

        LocalForward 3199 163.28.10.199:22

        LocalForward 3200 163.28.10.200:22

Host vm1

        ProxyCommand ssh 120.125.80.106 -W 163.28.10.197:22

Host vm2

        ProxyCommand ssh 120.125.80.106 -W 163.28.10.198:22

Host vm3

        ProxyCommand ssh 120.125.80.106 -W 163.28.10.199:22

Host vm4

        ProxyCommand ssh 120.125.80.106 -W 163.28.10.200:22

沒有留言: