【问题标题】:Mount remote file system using sshfs with a PHP script使用带有 PHP 脚本的 sshfs 挂载远程文件系统
【发布时间】:2022-01-21 09:26:28
【问题描述】:

我希望我的 PHP 脚本可以使用 sshfs 命令安装远程系统。 但这似乎不起作用,文件夹已创建,但执行后文件夹仍为空。我还尝试了一个没有 SU 的用户,它工作正常。

mkdir ("/var/mont/remote/");
$cmd = "sshfs -o password_stdin -o allow_other enzo@192.168.0.29:/home/enzo/remote/ /var/mont/remote/ <<< 'MyRemotePassword'";
$output = nl2br(shell_exec($cmd));
echo $output;

【问题讨论】:

    标签: php linux sshfs


    【解决方案1】:

    这个脚本(test.sh)应该可以工作:

    #!/usr/bin/env bash
    php -r 'mkdir ("/var/mont/remote");
            $cmd = "sshfs -o password_stdin -o allow_other enzo@192.168.0.29:/home/enzo/remote/ /var/mont/remote/ <<< 'MyRemotePassword'";
            $output = nl2br(shell_exec($cmd));
            echo $output;'
    

    bash test.sh 运行它

    【讨论】:

    • 具体应该怎么做?我创建一个 php 文件并粘贴它?
    猜你喜欢
    • 2010-11-11
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 2014-05-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多