
我需要訪問 IEEE xplore,但我無權從學院下載。
我可以透過ssh登入學院的伺服器,
那麼如何透過 ssh 透過學院伺服器存取 IEEE xplore?
我搜尋過解決方案,有人回答:
ssh -L 8080:localhost:80 user@remoteserver
然後他說:
現在,將本機瀏覽器指向 localhost:8080。它應該被轉發到遠端伺服器中的 localhost:80。
我非常感謝你的幫忙!
答案1
第一種方法:
啟動 SSH 隧道
要啟動 SSH 隧道,只需打開終端並使用以下標誌透過 SSH 連接到遠端伺服器:
ssh -D 8080 -C -N [email protected]
使用 SSH 隧道瀏覽網頁 (Chrome)
現在,讓我們開始使用新的 SSH 隧道瀏覽網頁。
- 開啟谷歌瀏覽器
- 選擇右上角的扳手圖標
- 選擇“設定”
- 選擇“顯示進階設定...”
- 選擇“更改代理設定...”
- 選擇“SOCKS 代理”
- 輸入“127.0.0.1”
- 輸入埠“8080”
- 選擇“確定”儲存更改
在 Google 中搜尋「我的 IP」並查看您現在的 IP 位址。
這將在連接埠 8080 上啟動 SSH 隧道,並透過 example.com 上的伺服器(安全地)路由所有流量。
退出 SSH 隧道
若要退出 SSH 隧道,只需在瀏覽器中停用 SOCKS 代理程式即可。
第二種方法:
您可以使用 Shellinabox 輕鬆完成
確保您已檢查 Universe 儲存庫
安裝
$ sudo apt-get install openssl shellinabox
配置 Shellinabox
預設情況下,shellinaboxd 偵聽本機上的 TCP 連接埠 4200。
$ sudo vi /etc/default/shellinabox
# specify the IP address of a destination SSH server
SHELLINABOX_ARGS="--o-beep -s /:SSH:172.16.25.125"
# if you want to restrict access to shellinaboxd from localhost only
SHELLINABOX_ARGS="--o-beep -s /:SSH:172.16.25.125 --localhost-only"
注意:將 ip 172.16.25.125 替換為您的 IP
啟動 Shellinabox
配置完成後就可以啟動服務了
$ sudo service shellinaboxd start
驗證 Shellinabox
現在讓我們使用「netstat」命令驗證 Shellinabox 是否在連接埠 4200 上運行。
$ sudo netstat -nap | grep shellinabox
or
# netstat -nap | grep shellinabox
tcp 0 0 0.0.0.0:4200 0.0.0.0:* LISTEN 12274/shellinaboxd
現在打開您的網頁瀏覽器,然後導航至“https://”Your-IP-Adress:6175”。您應該可以看到基於 Web 的 SSH 終端。使用您的使用者名稱和密碼登錄,您應該會看到 shell 提示字元。
答案2
您提供的範例是正確的,但有些誤導。這應該有效:
ssh -L 8080:<remote-web-host-you-want-to-see>:80 remote-user@remote-ssh-server
例如,考慮一個運行 ssh 的遠端機器可以存取此網頁,我想在本地查看該網頁:
要在本機上建立一個允許我瀏覽到該遠端頁面的隧道,我在本地運行:
ssh -L 8080:192.168.1.2:80 user@remote-ssh-server
然後,我在網頁瀏覽器中訪問:
http://localhost:8080/index.html
如果您需要(或想要)省略連接埠說明符,則需要以 root 身分開啟隧道,因為 80 是「特權」連接埠(<1024):
sudo ssh -L 80:<remote-web-host-you-want-to-see>:80 remote-user@remote-ssh-server
然後,您可以在本地訪問:
不需要其他配置。
順便說一下,這僅適用於單身的您想在本機查看的主機。如果您需要查看更多信息,則需要在其他連接埠上打開更多隧道,或檢查透過代理為所有遠端主機傳輸請求的其他解決方案。
-L
這是這個開關的第三次用法man ssh
:
-L [bind_address:]port:host:hostport
-L [bind_address:]port:remote_socket
-L local_socket:host:hostport
-L local_socket:remote_socket
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. This works by allocating a socket to
listen to either a TCP port on the local side, optionally bound to the
specified bind_address, or to a Unix socket. Whenever a connection is
made to the local port or socket, the connection is forwarded over the
secure channel, and a connection is made to either host port hostport,
or the Unix socket remote_socket, from the remote machine.
Port forwardings can also be specified in the configuration file. Only
the superuser can forward privileged ports. IPv6 addresses can be
specified by enclosing the address in square brackets.
By default, the local port is bound in accordance with the GatewayPorts
setting. However, an explicit bind_address may be used to bind the
connection to a specific address. The bind_address of “localhost”
indicates that the listening port be bound for local use only, while an
empty address or ‘*’ indicates that the port should be available from
all interfaces.