我有一个远程Linux的idebian)VPS,我想以某种方式附加到我的本地局域网,并给它一个本地的IP地址,所以我可以访问它,像这样的所有端口就在我身边。 我家也有一台debian服务器,一切都在路由器(DD-WRT)后面。 我会创造一种VPN来达到这个目的吗? 如果是这样,一个简短的介绍将是伟大的!
最简单的方法是执行SSH隧道并通过隧道安装驱动器。 另一种select是使用VPN – 这里的关注/问题是什么样的VPS
如果VPS是基于OpenVZ(para-virtulization)而不是你需要做的SSH隧道出于这个原因,我只会介绍SSH方法。
SSH可以为您提供远程计算机的身份validation和encryption连接。 如果您设置密钥,则可以在不使用密码的情况下进行连接。
系统将提示您input保存密钥和密码的文件。 只要继续前进,按回车 – 文件将被命名为id_dsa,您的私钥将不会被密码保护。
完成此操作后,您将在主目录的.ssh目录中看到id_rsa和id_rsa.pub。
最后一件事 – 你也应该这样做,反过来 – 这次把文件server2命名为类似的东西,所以你知道它们的不同之处 – 而且在做scp命令的时候一定要把filename.pub复制到另一个服务器上。
接下来我们将进入SSH隧道:
隧道是一个超级强大的概念,使您可以连接两台服务器,就好像它们是本地连接一样。
ssh -L localport:host:hostport user @ ssh_server -N
其中:-L – 端口转发参数(见下文)localport – 本地端口(select未被其他服务使用的端口)
host - server that has the port (hostport) that you want to forward hostport - remote port -N - do not execute a remote command, (you will not have the shell, see below) user - user that have ssh access to the ssh server (computer) ssh_server - the ssh server that will be used for forwarding/tunneling Without the -N option you will have not only the forwardig port but also the remote shell. Try with and without it to see the difference.
请记住 – 这可能需要有所不同,因为你可能需要先做一些端口转发
最后一件事是…
确保设置一个用户,不要使用ROOT。 为什么 – 因为如果你发送任何错误的东西 – 你不仅可以杀死连接,但你可以杀死一台机器或另一台机器…