我一直在尝试设置一个SSH反向隧道Systemd服务,以便自动将我的非公共IP计算机暴露在SSHing的互联网上。我有两个不同的服务,一个指向我自己的服务器(另一台有公共IP的计算机),运行正常,另一个试图使用serveo.net (通过ssh客户端的TCP隧道的免费服务)。我的服务在我自己的服务器上工作得很好,但在Serveo上却失败了。
我的服务定义如下:
[Unit]
Description=Setup a remote tunnel to serveo.net
Wants=network-online.target
After=network-online.target
StartLimitIntervalSec=0
[Service]
User=ssh-tunnel
Group=ssh-tunnel
ExecStart=/usr/bin/ssh -T -o ServerAliveInterval=60 -i /var/lib/ssh-tunnel/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ExitOnForwardFailure=yes -R myalias:58227:localhost:22 serveo.net
Restart=always
RestartSec=60
[Install]
WantedBy=multi-user.target当在终端执行相同的命令时,可以正常工作:
sudo -u ssh-tunnel -g ssh-tunnel /usr/bin/ssh -T -o ServerAliveInterval=60 -i /var/lib/ssh-tunnel/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ExitOnForwardFailure=yes -R myalias:58227:localhost:22 serveo.net我能看到的我自己的服务器和Serveo之间唯一的行为差异是Serveo有一种交互式的命令界面。
有没有人在Systemd服务上遇到过类似的问题?
发布于 2020-07-01 04:08:32
Serveo需要一个交互式shell。您想要添加
Service StandardInput=tty-force
强制使用与serveo配置一起工作的shell
https://stackoverflow.com/questions/62604573
复制相似问题