Answer the question
In order to leave comments, you need to log in
How to write SFTP get request in one line?
There was such task:
It is necessary to receive a remote file from a remote server, through SFTP, in one line.
To do this, there is an SFTP user, with a password (without it, too, in any way).
You also need to do it using a PHP file, let's say the exec () command - which executes commands as in the command line.
Tried all sorts of stupid options, like:
exec('sftp user:[email protected] get /home/www/x1/test/file.php /home/www/x2/test/file.php');
exec('sftp user:[email protected]:/home/www/x1/test/file.php /home/www/x2/test/file.php');
exec('sftp [email protected] && password && get /home/www/x1/test/file.php /home/www/x2/test/file.php');
Answer the question
In order to leave comments, you need to log in
If possible, install sshpass
sshpass -p <password> sftp <remote-username>@<remote-host>:/path/to/source /path/to/dest
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question