从服务器下载文件到本地(SSH端口转发)

ssh端口转发需求有些时候我们有这样一些需求1.阿里云的redis不能直接访问
2.测试回调代码的时候,只能通过服务器,没法本地调试解决方案1.通过安全组下的ECS服务器能通过内网访问redis,将ECS的6379端口转发的redis的6379端口,这样访问 redis-cli ECSip 6379 就能访问到redis服务器了

2.将回调请求发送到一台服务器,然后将服务器的请求通过端口映射转发到本地 localhost:8080,就可以在本地进行调试了ssh通道端口转发 将本地请求转发到服务上ssh -L <local-port>:<local-host>:<remote-port> <ssh remote-server>local-port 本地监听的端口号local-host 服务器地址remote-port 服务器ssh remote-server ssh服务的信息,如 [email protected]举个例子ssh -L 88888:localhost:8080 [email protected]

就是本地访问 localhost:8080,而请求会转发到 47.99.12.666:88888将服务器请求转发到本地ssh -L <remote-port>:<local-host>:<local-port> <ssh remote-server>在执行命令之前,首先要修改服务器里sshd一个配置:$ vim /etc/ssh/sshd_config

GatewayPorts yes

$ service sshd reload举例比如ssh -R 99999:localhost:8000 [email protected]

就是访问 http://47.99.12.666:99999, 请求会转发到 http://localhost:8000想要看更多技术方面的文章,请关注,以后会慢慢更新!

本文出自快速备案,转载时请注明出处及相应链接。

本文永久链接: https://kuaisubeian.cc/34059.html

kuaisubeian