我正在关注有关如何运行反向ssh隧道的教程,该教程位于http://wiki.fabelier.org/index.php?title=Permanent_Reverse_SSH_Tunneling上,当我运行tunneling.sh脚本时遇到的问题是:

#!/bin/sh
a=`ps -ef | grep 19999 | grep -v grep`
if [ ! "$a" ]; then
    ssh -fN -R 19999:localhost:22 <middle-usename>@<middle-hostname>
fi

我收到此错误:
tunnel2.sh: 2: tunnel2.sh: a: not found

编辑:

我将shebang更改为#!/bin/bash

现在我得到这个错误:
tunnel2.sh: 2: tunnel2.sh: pi: not found

最佳答案

如果要使用bash功能,请不要在“shebang”行中指定#!/bin/sh。如果您想要bash,请要求bash。

09-26 10:17