无法创建 OpenSSH 隧道

无法创建 OpenSSH 隧道

我正在尝试通过 openssh 设置 VPN。

我在 Arch Linux 上运行客户端。客户端的版本是OpenSSH_7.7p1, OpenSSL 1.1.0h 27 Mar 2018.

ssh 服务器位于 Google Cloud 上的 Ubuntu 17.10 版本 上OpenSSH_7.5p1 Ubuntu-10ubuntu0.1, OpenSSL 1.0.2g 1 Mar 2016。在服务器配置中,我启用了各种转发以及PermitTunnel选项。我已经重新启动了 sshd 守护进程。apparmor为了以防万一,我也禁用了。没有 selinux 正在运行。我也这样做modprobe tun以防万一(尽管 openvpn 例如工作没有问题)。该服务器在 Google Cloud 和 Ubuntu 级别上都启用了 ip 转发。ufw已禁用并且Google防火墙已完全打开。

首先我尝试使用以下命令进行连接:

sudo ssh -i ssh_key -w any:any root@ip -vvv -o Tunnel=point-to-point

以上失败,并且 ssh 在失败点附近的调试输出为:

debug1: Authentication succeeded (publickey). Authenticated to xxxxxxxx. debug1: Requesting tun unit 1 in mode 1 debug1: sys_tun_open: tun1 mode 1 fd 4 Tunnel device open failed. Could not request tunnel forwarding. debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0

由于上述失败,我认为我应该首先创建 tun 设备。这就是我所做的:

在客户端: sudo ip tuntap add tun1 mode tun sudo ip link set tun1 up sudo ip addr add 172.32.0.1/24 peer 172.32.0.2 dev tun1

在服务器上: sudo ip tuntap add tun1 mode tun sudo ip link set tun1 up sudo ip addr add 172.32.0.2/24 peer 172.32.0.1 dev tun1

但这又以同样的方式失败了。

我尝试在本地计算机上运行 sshd 服务器并连接到本地主机。但后来又以同样的方式失败了。

我尝试了本地端口转发并且成功了。

如何使用 openssh 正确设置 VPN?我彻底搜索了网络,但没有任何帮助。

答案1

我的 Arch Linux 也有同样的问题。 ArchLinux安装在客户端和服务器上。 openssh 的版本是7.7p1-1.作为临时解决方案,我安装了 openssh 版本7.6p1-2

答案2

与 OpenSSH_7.7p1 Debian-2、OpenSSL 1.0.2o 2018 年 3 月 27 日出现同样的问题。

使用以下脚本降级 ssh 后:

wget http://ftp.us.debian.org/debian/pool/main/o/openssh/openssh-client_7.4p1-10+deb9u3_amd64.deb
wget http://ftp.us.debian.org/debian/pool/main/o/openssh/openssh-sftp-server_7.4p1-10+deb9u3_amd64.deb
wget http://ftp.us.debian.org/debian/pool/main/o/openssh/openssh-server_7.4p1-10+deb9u3_amd64.deb
dpkg -i *.deb
systemctl restart ssh
systemctl status ssh

VPN 再次开始工作。

相关内容