ssh通过http代理访问服务器

centos 7,root user

install:Get Corkscrew

download: https://pkgs.org/download/corkscrew

Add ProxyCommand to your SSH config file:

You may or may not have a configuration file for SSH already. It should be located in $HOME/.ssh/config and is a simple text file. Create one if it does not exist and add lines such as these to it:

Host *
ProxyCommand corkscrew http-proxy.example.com 8080 %h %p

… replacing http-proxy.example.com with the name or address of your http proxy and possibly replacing 8080 with the port on which the proxy listens, which may be 80 or even some other port. The %h and %p will be replaced automatically by SSH with the actual destination host and port.

These two lines tell the SSH client to start another program (corkscrew) to make the actual connection to the SSH server. The Host * line says that this will be done for ALL hosts. If you wish to restrict the hosts for which this will be done, you can put a limited form of regular expression there. See the ssh_config(5) man page for more information. If you don’t have corkscrew in your path or have put it in a non-standard location, you may specify an absolute path to corkscrew in that file as well.

example

ssh username@ip -p port
scp -P port -r ./test username@ip:/home/test/

from:

https://www.mtu.net/~engstrom/ssh-proxy.php

如果您需要在SSH服务上设置代理访问HTTP网站,您可以按照以下步骤进行操作: 1. 安装和配置SSH服务器:请按照前面提到的步骤安装和配置SSH服务器。 2. 配置SSH代理设置:在SSH服务器配置文件(`/etc/ssh/sshd_config`)中,找到`AllowTcpForwarding`选项,并确保其值为`yes`。这将允许TCP转发。 3. 重启SSH服务器:保存配置更改后,重新启动SSH服务器使更改生效。 4. 连接到SSH服务器:使用SSH客户端工具连接到您的SSH服务器。 5. 设置本地端口转发:在SSH连接中,使用以下命令设置本地端口转发: ``` ssh -L <本地端口>:<目标网站>:<目标端口> <SSH服务器地址> ``` 请将`<本地端口>`替换为您希望本地计算机上的代理监听的端口号,`<目标网站>`和`<目标端口>`替换为您要访问HTTP网站的地址和端口号,`<SSH服务器地址>`替换为您的SSH服务器的地址。 例如,要将本地端口8080映射到目标网站example.com上的80端口,可以运行以下命令: ``` ssh -L 8080:example.com:80 user@ssh-server ``` 6. 配置本地代理设置:在您的本地计算机上,将您的HTTP代理设置指向`localhost`和使用上一步中设置的本地端口号(例如8080)。 7. 测试代理访问:在您的浏览器或其他应用程序中,尝试访问HTTP网站。流量将通过SSH隧道转发到目标网站。 请注意,这种方法只能用于HTTP代理,如果需要使用HTTPS代理,还需要进行额外的配置。此外,确保您遵守所有适用法律和网络服务提供商的条款。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值