Answer the question
In order to leave comments, you need to log in
How to mount virtual disk via SSHFS using PHP?
How to mount virtual disk via SSHFS using PHP ?
SERVER_IP - IP of the server I'm connecting to.
PASSWORD - the actual password of the remote user.
/mnt/ssh_drive - path to mount.
Through the console I do this -
echo PASSWORD | sshfs -C -p 22 -o allow_other [email protected]_IP:/ /mnt/ssh_drive -o password_stdin
shell_exec("echo PASSWORD | sshfs -C -p 22 -o allow_other [email protected]_IP:/ /mnt/ssh_drive -o password_stdin")
Nothing happens. #!/bin/bash
echo 'PASSWORD' | sshfs -C -p 22 -o allow_other [email protected]_IP:/ /mnt/ssh_drive -o password_stdin
Answer the question
In order to leave comments, you need to log in
php.net/manual/en/function.shell-exec.php read "Remarks".
try another function instead of shell_exec, for example system or exec
I use quotes for such operations
$x = `echo 'PASSWORD' | sshfs -C -p 22 -o allow_other [email protected]_IP:/ /mnt/ssh_drive -o password_stdin`;
echo $x;
Of course, nothing will happen to you,
and for this you will have to understand from which user your php is running and is he allowed to mount something at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question