【问题标题】:issue with restarting autossh reverse tunnel on boot启动时重新启动 autossh 反向隧道的问题
【发布时间】:2019-04-13 15:12:50
【问题描述】:

我似乎有一个奇怪的问题: 我想在启动时重新启动反向 ssh 隧道,我已经尝试使用 init 脚本(以用户身份执行时可以正常工作)并在/etc/rc.d 中添加了一行,但它都不起作用。启动后我得到的是:

$ ps ax  | grep autossh
  397 pts/10   S+     0:00 grep --color=auto autossh
 1351 ?        Ss     0:00 /usr/lib/autossh/autossh -M 22221    -N -o PubkeyAuthentication=yes -o PasswordAuthentication=no -i ~/.ssh/etherwan.key -R 19999:localhost:22 ubuntu@server

但我无法从server 登录。所以我在启动后做了以下操作:

$ sudo killall -KILL autossh
[sudo] password for ron: 
$ /usr/bin/autossh -M 22221 -f -N -o "PubkeyAuthentication=yes" -o "PasswordAuthentication=no" -i ~/.ssh/etherwan.key -R 19999:localhost:22 ubuntu@server

我可以使用端口 19999 登录就好了!

密钥权限看起来像:(但 root 不需要关心,不是吗?)

$ ls -l ~/.ssh/etherwan.key
-r-------- 1 ron ron 1675 Nov  6 04:15 /home/ron/.ssh/etherwan.key

【问题讨论】:

    标签: linux boot ssh-tunnel autossh rc.d


    【解决方案1】:

    rc.d 脚本中的 ~/.ssh/etherwan.key 替换为 /home/ron/.ssh/etherwan.key

    '~' 字符由 shell 扩展至用户的主目录,但 rc.d 脚本以 root 身份运行。

    【讨论】:

      猜你喜欢
      • 2021-05-23
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 2019-04-24
      • 2019-03-03
      • 2010-12-21
      • 2015-12-12
      • 2011-10-09
      相关资源
      最近更新 更多