php - sftp/scp files with bash -


i have need upload set of files sftp account.

my first thought use php's ssh2_connect() function , able working locally no problem. however, once moved dev environment realized wasn't solution because there many dependencies wont exist , installing them require many approvals many people.

so, next thought use bash, , need help. running bash script every hour through cron, needs unattended. however, when run sftp/scp requires password.

the sftp account not allow ssh connections cannot create authorized keys. don't want rely on .ssh folder on remote machine well.

any suggestions appreciated.

keep in mind cannot install anything, no keychain, sshpass or expect. other answers found in how run sftp command password bash script? not feasible cannot install on server.

initially trying use php's ssh2_connect() because php creates file need upload. it's better have sftp transaction in php script reason since wasn't working, moved on bash.

my solution using php , curl:

$ch = curl_init();  $fp = fopen($file, "r");  curl_setopt($ch, curlopt_url, "sftp://user:pass@host/" . basename($file)); curl_setopt($ch, curlopt_upload, 1); curl_setopt($ch, curlopt_protocols, curlproto_sftp); curl_setopt($ch, curlopt_infile, $fp); curl_setopt($ch, curlopt_infilesize, filesize($file));  curl_exec($ch);  curl_close($ch); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -