【问题标题】:Running bash via ssh shows error: /usr/bin/env: bash: No such file or directory通过 ssh 运行 bash 显示错误:/usr/bin/env: bash: No such file or directory
【发布时间】:2021-05-02 16:19:34
【问题描述】:

这是我的 test.sh:

#!/usr/bin/env bash
echo succeed

当我从本地运行它时,一切正常:

[jerry@Jerry-DELL ~]$ ./test.sh
succeed

但是,当我通过 ssh 运行它时:

[jerry@Jerry-DELL ~]$ ssh localhost /home/jerry/test.sh
/usr/bin/env: 'bash': No such file or directory

然后,当我将“/usr/bin/env bash”更改为“/bin/bash”时,它可以工作:

[jerry@Jerry-DELL ~]$ ssh localhost /home/jerry/test.sh
succeed

那么,有什么问题吗?我该如何解决?顺便说一句,我在 Manjaro 上使用 openssh8.6。

【问题讨论】:

    标签: bash ssh archlinux


    【解决方案1】:

    当您执行 ssh 时,确保 /bin 在您的 $PATH 中(通过 ~/.bash_profile 或 ~/.bashrc)。

    检查它:

    ssh localhost 'echo $PATH'
    

    【讨论】:

      猜你喜欢
      • 2014-01-20
      • 2022-08-15
      • 2021-03-28
      • 2017-04-27
      • 2018-12-23
      • 2014-11-06
      • 2020-06-30
      • 2014-12-16
      • 2013-08-12
      相关资源
      最近更新 更多