穿透防火牆進到內部機器

情境 : 想要直接登入某台機器可是該台機器躲在防火牆後面, 以往都需要登入非DMZ的機器. 再跳入該機器. 例如我有一台 gate.liho.tw 的機器可以讓外面網路的人登入. 但是我想進去躲在防火牆後面的 aloha 機器. 以往我都是先登入 gate.liho.tw 再登入 aloha 機器. 一開始我用下列指令 :

# ssh gate.liho.tw "ssh aloha"

但出現下面的錯誤 :

Pseudo-terminal will not be allocated because stdin is not a terminal.

後來 google 一下找到 ssh error: Pseudo-terminal will not be allocated because stdin is not a terminal 這篇文章.

在 ssh manual 有寫 :

-T Disable pseudo-tty allocation.

-t Force pseudo-tty allocation. This can be used to execute arbi-
trary screen-based programs on a remote machine, which can be
very useful, e.g., when implementing menu services. Multiple -t
options force tty allocation, even if ssh has no local tty.

參考了上面的訊息後, 多用一個 “-t” 這樣就沒問題了.

# ssh gate.liho.tw -t "ssh aloha"

我真是厲害 😀

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.