有时候浏览器连不上外网查看技术代码,估计被干了,可以使用SSH代理转发。
快捷方式连接参数可以设置
putty.exe -D 127.0.0.1:8080 -pw 密码 root@服务器地址
或者使用批处理
putty -N -ssh root@服务器地址 -P 22 -pw 密码 -C -D 127.0.0.1:8080
或者调换顺序
putty -C -N -D 127.0.0.1:10800 -P 22 -pw 密码 root@服务器地址
-f
输入密码后进入后台模式
(Requests ssh to go to background just before command execution.)
-N
不执行远程命令,用于端口转发
( Do not execute a remote command. This is useful for just for warding ports (protocol version 2 only).)
-D
socket5代理
(Specifies a local “dynamic” application-level port forwarding.Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server.)
-L
tcp转发
(Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.)
-C
使用数据压缩,网速快时会影响速度
(Compression is desirable on modem lines and other slow connections, but will only slow down things on fast networks.The compression algorithm is the same used by gzip)
其中127.0.0.1:8080 是在本地创建一个8080端口的socks
如此,你的浏览器设置127.0.0.1:8080 即可通过你的vps服务器上网
或者 chrome 游戏安装Proxy SwitchySharp插件
https://chrome.google.com/webstore/detail/proxy-switchysharp/dpplabbmogkhghncfbfdeeokoefdjegm?
putty官方
https://www.chiark.greenend.org.uk/~sgtatham/putty/
另外Xshell,SecureCRT等都可以。
解决dns慢的问题
可以在服务器端配置文件/etc/hosts文件中把你本机的ip和hostname加入
可以在服务器端配置文件/etc/resolv.conf 注释掉所有行
可以在服务器端配置文件/etc/nsswitch.conf
hosts 更改 hosts: files
也就是去掉尾部的dns
可以在服务器端配置文件/etc/ssh/sshd_config 中
更改UseDNS=no
修改GSSAPIAuthentication no
sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
/etc/init.d/sshd restart
systemctl restart sshd
默认走的是ssh的dns查询,若要使用自定义的
firefox和chrome可以实现,其它浏览器不懂了
Firefox远程DNS解析设置方法是:
在火狐地址栏输入
about:config
点“我保证会小心”。
在过滤器中输入
network.proxy.socks_remote_dns
双击,修改值为ture,关闭页面。
Chrome 已经添加了远程域名解析功能,使用 Proxy Switchy 设置 Socks5 代理之后,访问自动会启用远程DNS解析。或者启动参数 –dns-server=4.2.2.1