大网数据广告活动
服务器运维问答

How to make ssh based vpn?

· 52CE 我爱测

I have some problems with making ssh-based VPN. Situation: LOCAL -> GATE -> SERVICES (ssh server) (Many other servers with some services) 192.168.0.10 10.1.0.154 172.26.106.0/24 255.255.255.0 255.255.0.0 From LOCAL I can login th…

问题原文

原帖链接 · devstructor · CC BY-SA 3.0

I have some problems with making ssh-based VPN.

Situation:

LOCAL ->            GATE                 -> SERVICES 
                (ssh server)     (Many other servers with some services)
192.168.0.10     10.1.0.154             172.26.106.0/24
255.255.255.0    255.255.0.0

From LOCAL I can login through the ssh to the GATE and then from here I have access to all of the SERVICES servers.

However i want to access services directly from my LOCAL computer. How can I acheive this?

Here is what i tried to do after reading ssh manual:

On LOCAL:

# ssh -f -w 1:2 root@GATE true
# ifconfig tun1 10.66.1.1 10.66.1.2 netmask 255.255.255.252
# route add -net 172.26.106.0 netmask 255.255.255.0 gw 10.66.1.2 

On GATE:

# ifconfig tun2 10.66.1.2 10.66.1.1 netmask 255.255.255.252

It doesn't work. I get timeouts when i try to ssh to some SERVICE from LOCAL ;-(

已采纳解答

原帖链接 · devstructor · CC BY-SA 4.0

Two and half year left since I asked that question... Now I found another solution which is extremely simple. You can just use tool called sshuttle.

From sshuttle manual:

sshuttle allows you to create a VPN connection from your machine to any remote server that you can connect to via ssh, as long as that server has python 2.3 or higher.

i.e.:

sshuttle -r user@gate 172.26.100.0/24 172.26.106.0/24 172.26.103.0/24

Then in another terminal you can do ssh to any server from routed subnets directly:

i.e.:

ssh [email omitted]

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-06-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。