通过ssh访问网页

uly*_*is2 19 ssh html localhost

我需要访问 IEEE xplore,但我无权从研究所下载。

我可以通过ssh登录到研究所的服务器,

那么如何通过ssh通过学院服务器访问IEEE xplore?

我已经搜索了解决方案,有一个答案:

ssh -L 8080:localhost:80 user@remoteserver
Run Code Online (Sandbox Code Playgroud)

然后他说:

现在,将本地浏览器指向 localhost:8080。它应该转发到远程服务器中的 localhost:80。### 但我仍然不知道如何配置我的笔记本电脑,我使用的是 chrome。

我非常感谢你的帮助!

May*_*hux 28

第一种方法:

启动 SSH 隧道

要启动您的 SSH 隧道,只需打开终端并使用以下标志通过 SSH 连接到您的远程服务器:

ssh -D 8080 -C -N username@example.com
Run Code Online (Sandbox Code Playgroud)

使用 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
Run Code Online (Sandbox Code Playgroud)

配置 Shellinabox

默认情况下,shellinaboxd 侦听本地主机上的 TCP 端口 4200。在安装过程中,会在“/var/lib/shellinabox”下自动创建一个新的自签名 SSL 证书以使用 HTTPS 协议。

$ 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"
Run Code Online (Sandbox Code Playgroud)

注意:用你的 ip 172.16.25.125 替换

启动 Shellinabox

完成配置后,您可以启动服务

$ sudo service shellinaboxd start
Run Code Online (Sandbox Code Playgroud)

验证 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
Run Code Online (Sandbox Code Playgroud)

现在打开您的网络浏览器,并导航到“https://"Your-IP-Adress:6175"”。您应该能够看到基于 Web 的 SSH 终端。使用您的用户名和密码登录,您应该会看到您的 shell 提示。

在此处输入图片说明

来源

  • @maythus,非常感谢你,你的回答很好。我用解决方案1解决了我的问题。 (2认同)

Tre*_*vor 12

您提供的示例是正确的,但有些误导。这应该有效:

ssh -L 8080:<remote-web-host-you-want-to-see>:80 remote-user@remote-ssh-server
Run Code Online (Sandbox Code Playgroud)

例如,考虑一个运行 ssh 的远程盒子,它可以访问这个网页,我想在本地看到它:

http://192.168.1.2/index.html

为了在我的本地机器上创建一个允许我浏览到那个远程页面的隧道,我在本地运行:

ssh -L 8080:192.168.1.2:80 user@remote-ssh-server
Run Code Online (Sandbox Code Playgroud)

然后,在网络浏览器中,我访问:

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
Run Code Online (Sandbox Code Playgroud)

然后,您可以在本地访问:

http://localhost/index.html

不需要其他配置。

顺便说一句,这仅适用于您想在本地查看的单个主机。如果您需要查看更多信息,您要么需要在其他端口上打开更多隧道,要么检查通过代理对所有远程主机进行隧道请求的其他解决方案。

这是-Lswitch的第三次使用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.
Run Code Online (Sandbox Code Playgroud)

  • 奇迹般有效!非常感谢! (2认同)
  • 比接受的答案好得多! (2认同)