小编spa*_*ots的帖子

建立持久的 autossh 反向 ssh 隧道

任何人都可以向我指出一个好的(逐步)资源的方向,用于在启动时使用 systemd 使用 autossh 设置反向 ssh 隧道吗?

我已尽力使用我在网上找到的资源来做到这一点,并成功地手动创建了反向 ssh 会话,但是还没有设法使用 systemd 使其自动化,以便我的“远程”系统可以重新启动而不会引起问题。

我正在尝试使用本教程建立持久的 autossh 会话,但是当我运行时,sudo systemctl enable autossh.service我不断遇到此错误:update-rc.d: error: cannot find a LSB script for autossh

任何帮助破译此错误或在 Ubuntu 20.04 上创建持久 autossh 会话的帮助将不胜感激。

autossh.service文件:

[Unit]
Description=Establish persistent SSH tunnel
Requires=ssh.service
Wants=network-online.target
After=network-online.target

[Service]
User=user
Group=usergroup
Environment=AUTOSSH_POLL=60 AUTOSSH_FIRST_POLL=30 AUTOSSH_LOGFILE=/var/log/autossh.log AUTOSSH_LOGLEVEL=7 AUTOSSH_GATETIME=0
ExecStart=/usr/bin/autossh -i /root/.ssh/id_rsa -R 3010:localhost:22 -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null' -o 'PasswordAuthentication=no' -o 'PubkeyAuthentication=yes' -o 'ServerAliveInterval 60' -o 'ServerAliveCountMax 3' -o 'BatchMode=yes' user@myddnsservice -p2016
RestartSec=6
Restart=always …
Run Code Online (Sandbox Code Playgroud)

ssh autossh

4
推荐指数
1
解决办法
4808
查看次数

标签 统计

autossh ×1

ssh ×1