通过 ssh 访问网页

通过 ssh 访问网页

我需要访问 IEEE xplore,但我没有从研究所下载的权限。

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

那么我如何通过 ssh 通过研究所服务器访问 IEEE xplore?

我搜索过解决方案,有人回答:

ssh -L 8080:localhost:80 user@remoteserver

然后他说:

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

非常感谢您的帮助!

答案1

第一种方法:

启动 SSH 隧道

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

ssh -D 8080 -C -N [email protected]

使用 SSH 隧道浏览网页(Chrome)

现在,让我们开始使用新的 SSH 隧道浏览网页。

  • 打开 Google Chrome
  • 选择右上角的扳手图标
  • 选择“设置”
  • 选择“显示高级设置…”
  • 选择“更改代理设置…”
  • 选择‘SOCKS代理’
  • 输入“127.0.0.1”
  • 输入端口‘8080’
  • 选择“确定”保存更改

在 Google 上搜索“我的 IP”,看看您现在的 IP 地址是多少。

这将在端口 8080 上启动我们的 SSH 隧道并通过 example.com 上的服务器(安全地)路由所有流量。

退出 SSH 隧道

要退出 SSH 隧道,只需在浏览器中禁用 SOCKS 代理。

来源

第二种方法:

您可以使用 Shellinabox 轻松完成

确保您已经检查过 Universe Repository

安装

 $ sudo apt-get install openssl shellinabox

配置 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"

注意:将 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””。你应该能够看到一个基于网络的 SSH 终端。使用你的用户名和密码登录,你应该会看到你的 shell 提示符。

在此处输入图片描述

来源

答案2

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

ssh -L 8080:<remote-web-host-you-want-to-see>:80 remote-user@remote-ssh-server

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

http://192.168.1.2/index.html

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

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

然后,您只需在本地访问即可:

http://localhost/index.html

无需其他配置。

顺便说一句,这只适用于单身的您想要在本地查看的主机。如果您需要查看更多内容,则需要在其他端口上打开更多隧道,或者检查通过代理为所有远程主机隧道传输请求的其他解决方案。

这是第三次使用该-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.

相关内容