创建自己的免费 ssh -D 服务器

来源:隐清堂

由于某些原因,之前使用的国外 sshd 服务器不能再用了,如果还想像以前那样使用 ssh -D 翻墙的话,估计是要掏腰包啦。当然还有另外一种免费翻墙的办法,就是 vpn ,  比较常用的也就是 ultravpn , 这种方式的缺点就是,它是全局代理,访问国内站点时有点慢(当然可以用路由表解决,不过有点麻烦,关键是我不会 :-))。下面就介绍一种方法利用 ultravpn 创建自己的免费 ssh -D 服务器。

我们要用的工具是 VMware (或者是 Virtualbox) ,   windows xp安装盘(或映像文件),一个 vpn 账号, cygwin。

关于如何安装一个虚拟 windows 和如何申请一个 vpn 账号 ,在这里我就不说了,网上教程很多。(当然你也可以虚拟一个 linux , 考虑到有很多网友对 linux 不是很熟悉,而且在 windows 下连接 vpn 服务器更方便一些,我这里就只介绍如何在  windows 下创建 ssh -D 服务器 )

现在假定你已经有了一个虚拟的 windows (最好把 windows 防火墙关掉) 和一个 vpn 账号。为了方便我们在虚拟的 windows 下创建另一个管理员账号,并且设上密码 。

去 这里 下载 cygwin 安装文件,安装时直接下一步就可以了,在其中选择镜像时推荐使用德国的一个镜像(ftp.gwdg.de),如下图

cygwin1

然后在选择软件包里,注意一定要选择 在 net 分类下的 openssh 包,如下图:

cygwin2

cygwin3

然后直接一路下一步完成就可以了。

配置 sshd 服务

接着双击桌面上的 cygwin 快捷方式,在 cygwin 里输入如下命令:

chmod +r /etc/passwd

chmod +r /etc/group

chmod -R 777 /var

ssh-host-config

在提示 yes/no 时,都输入 yes, 如下:

*** Info: Generating /etc/ssh_host_key

*** Info: Generating /etc/ssh_host_rsa_key

*** Info: Generating /etc/ssh_host_dsa_key

*** Info: Creating default /etc/ssh_config file

*** Info: Creating default /etc/sshd_config file

*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.

*** Info: However, this requires a non-privileged account called 'sshd'.

*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ

ME.privsep.

*** Query: Should privilege separation be used? (yes/no) yes

*** Info: Note that creating a new user requires that the current account have

*** Info: Administrator privileges.  Should this script attempt to create a

*** Query: new local account ’sshd’? (yes/no) yes

*** Info: Updating /etc/sshd_config file

*** Info: Added ssh to C:\WINDOWS\system32\driversc\services

*** Warning: The following functions require administrator privileges!

*** Query: Do you want to install sshd as a service?

*** Query: (Say “no” if it is already installed as a service) (yes/no) yes

*** Info: Note that the CYGWIN variable must contain at least “ntsec”

*** Info: for sshd to be able to change user context without password.

*** Query: Enter the value of CYGWIN for the daemon: [ntsec] 这里直接回车

*** Info: The sshd service has been installed under the LocalSystem

*** Info: account (also known as SYSTEM). To start the service now, call

*** Info: `net start sshd’ or `cygrunsrv -S sshd’.  Otherwise, it

*** Info: will start automatically after the next reboot.

*** Info: Host configuration finished. Have fun!

然后启动 sshd 服务器:

cygrunsrv -S sshd

连接 vpn 服务器,具接步骤就不再说明了。

在虚拟 windows 下找到其 ip 地址,如下图

ip

然后在你自己的真实系统里,启动 myentunnel , 在地址栏填上虑拟机的 ip , 用户名和密码分别用虚拟 windows 的用户名和密码。

myent

然后,你可以参考 这篇 文章,配置代理使连接被墙网站时使用代理了。


3 条评论:

Unknown 说...

支持一个。

雁渡寒潭 风过疏林 说...

为了翻个墙装虚拟机,lz,太耗系统资源了吧?还是用用tor、jap啦。

大炮 说...

不就是连个vpn么哪有这么麻烦。。用mac或者是linux超级简单的。。