簡體   English   中英

通過ssh隧道遠程運行ipython筆記本

[英]run ipython notebook remotely through ssh tunneling

我想知道我是否可以通過ssh遠程使用ipython筆記本兩次。 場景是:機器B是我想運行ipython筆記本的機器。 但是,我只能先通過另一台服務器(機器A)訪問機器B. 有關於遠程使用ipython筆記本的教程,但沒有一個提到我遇到過的情況。

提前致謝 !

假設您指的是ssh隧道,並且ipython筆記本正在機器B上的端口1234上進行服務:

如果機器A可以訪問任何端口上的機器B,您可以設置機器A通過SSH轉發遠程端口:

ssh -L 9999:machineB.com:1234 -N machineA.com

這說

ssh到machineA.com而不執行遠程命令(-N)並設置機器A以通過ssh隧道從客戶端端口9999轉發請求到機器B端口1234

但是,如果機器A只能通過ssh訪問機器B,那么您將需要創建兩個隧道。 一個從客戶端PC到machineA,另一個從machineA到machineB。 為此,兩個隧道連接到machineA上的本地端口而不是遠程端口:

ssh -L 9999:localhost:8888 machineA.com ssh -L 8888:localhost:1234 -N machineB.com

這說

ssh到machineA.com並設置機器A通過ssh隧道從我們的客戶端PC端口9999轉發請求到機器A端口8888.然后執行命令“ssh -L 8888:localhost:1234 -N machineB.com”。 此命令設置從machineA端口8888到machineB端口1234(iPython正在偵聽的位置)的第二條隧道。

現在,在后台運行該命令,連接到本地PC端口9999.第一個ssh隧道將該請求轉發到machineA,它連接到localhost:8888,第二個ssh隧道然后將它轉發到machineB,在那里它連接到本地主機:1234。

請注意,machineA需要能夠自動連接到machineB(使用公鑰/私鑰認證)才能在單個命令中工作。

這是一篇很好地解釋ssh隧道的帖子https://superuser.com/questions/96489/ssh-tunnel-via-multiple-hops

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM