使用ssh访问外部网站

由于国内的环境,许多外部的服务都无法使用。被认为是轻而易举能够得到的资源,在内地只能是可望而不可即。

从另一方面讲,这促进了国人翻墙技术的发展。各种翻墙软件在这个环境下催生,并有各自的用户和市场。许多人被逼着去学相关技术,最后还可能成为了高手,不得不说要感谢国家啊!

之前一直使用goagent这个软件,到如今google服务经常性被封杀,这个软件可使用的范围越来越少。因为打算申请adsense的账号,不得不翻墙。现在觉得比较靠谱的是使用ssh翻墙。

之前使用过squid代理,可惜如果服务器在境外,经过路由的时候直接就被丢掉了。现在想来squid代理只能在内网使用,放到外网上基本上是死路一条。没办法,只能寻找更安全的代理抓取外部网页的办法。

配置vpn服务器是一种解决办法,由于配置繁琐,直接就放弃了。最后想到的那就尝试用ssh代理吧。

使用ssh代理,需要你有一台外部的vps,最好是国外的,能够访问各种所需服务。假设你可ssh连接到vps,如下步骤可建成一个代理服务器:

  1. ssh -D127.0.0.1:8080 user@host

    使用-D参数绑定监听。上述命令中我们监听的端口是8080.如果你知道-N和-T参数的含义,上述命令可以改为: ssh -NT -D *:8080,这里我们监听所有的来源而不限于本机(127.0.0.1)。通过这样做,可以对外提供服务。

  2. 配置浏览器的代理。我使用的是switchysharp这个插件,在配置里找到socks代理,主机填写127.0.0.1,端口填写刚才使用的8080端口,协议版本选择socks v5.0。

  3. 保存配置,并且启用该配置,就可以看到能够顺利访问外部站点资源了。

ssh代理的原理如下: 用户的请求直接走ssh的通道向远程服务器发起请求。由于ssh是加密连接,内容不能被外部监听,所以只要能连到服务器就有效。而squid之类的代理,首先还是要通过http方式请求服务器,中间路由一看到请求的地址,然后就干掉了。

此代理的限制: 在使用过程中应当保持ssh会话一直连接。由于请求是通过ssh通道传递,所以要保证ssh会话有效。使ssh处于不断线状态可在服务器上做如下配置:vim /etc/ssh/sshd_config,将下面配置启用:

    ClientAliveInterval 60
    ClientAliveCountMax 3    

然后重启sshd服务: service sshd restart·

下次再次连接进来,即可发现会话会一直保持,就可以愉快的上网了。

留言评论

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select * from vps_autoblog_queue where is_running >0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=6 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=6 and source_url_key='85f8e27ce55bd78fd33f47d2b1409198'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(6,'https://www.hijk.pw/post-sitemap.xml','85f8e27ce55bd78fd33f47d2b1409198',1750609641,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=4 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=4 and source_url_key='54b1dccf98c13c81f546faf82132bc77'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(4,'https://ssr.tools/sitemap-posttype-post.2020.xml','54b1dccf98c13c81f546faf82132bc77',1750609641,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=2 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=2 and source_url_key='91372ddcd9e4809b115feaa5b6f00815'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(2,'https://tlanyan.me/post-sitemap.xml','91372ddcd9e4809b115feaa5b6f00815',1750609641,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=7 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=7 and source_url_key='569e17863f7693f1afa9e9256af9dcff'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(7,'https://aisoa.cn/sitemap.xml','569e17863f7693f1afa9e9256af9dcff',1750609641,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=9 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=9 and source_url_key='cc9416f8df40d8c3a48e66856b1cd6fd'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(9,'https://www.v2rayssr.com/sitemap.xml','cc9416f8df40d8c3a48e66856b1cd6fd',1750609641,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select count(*) from vps_autoblog_queue where task_id=10 and is_running>0

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,fetched,is_running,last_date_time from vps_autoblog_queue where task_id=10 and source_url_key='74714f67855820f0c701ce905b231f27'

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
insert into vps_autoblog_queue(task_id,source_url,source_url_key,create_date_time,not_check_stoped,post_interval) values(10,'https://doubibackup.com/sitemap.xml','74714f67855820f0c701ce905b231f27',1750609641,0,0)

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,is_running,last_post_time,post_interval,not_check_stoped from vps_autoblog_queue WHERE is_running>0 and fetched=0 order BY id ASC

WordPress数据库错误: [Table 'ssrvps.vps_autoblog_queue' doesn't exist]
select id,sn_id from vps_autoblog_queue WHERE is_running=0 and fetched=0 order BY id ASC LIMIT 1