[英]SCP transfer a file from localhost to a sftp server through php script
Hi Trying to send a file to another server using scp.. cannot use sftp as it is not installed on my server so i am getting a function not found for ssh2_connect. 您好尝试使用scp将文件发送到另一台服务器。无法使用sftp,因为它未安装在我的服务器上,因此我无法找到ssh2_connect的功能。
So my only option as i can see it is scp. 因此,我能看到的唯一选择是scp。 Now the problem come with i cannot include my password in the php scp script.
现在问题来了,我无法在php scp脚本中包含密码。
ie: 即:
scp filename username:passwor@server:filename
It gives me the error that the server username doesn't exist If i use it without the password 它给我的错误是服务器用户名不存在,如果我没有密码就使用它
scp filename username@server:filename
it prompts me for password 它提示我输入密码
PS: I am testing the script in a command line on the localhost first as to get the error messages. PS:我首先在本地主机上的命令行中测试脚本,以获取错误消息。
Any advice? 有什么建议?
TA TA
If you can't use the SFTP binaries you could use phpseclib - a pure-PHP SFTP implementation: 如果您不能使用SFTP二进制文件,则可以使用phpseclib-纯PHP SFTP实现:
http://phpseclib.sourceforge.net/ http://phpseclib.sourceforge.net/
Kevin, if you don't have the PHP SSH2 extension installed on your server then your best bet is to setup public/private key authentication on your other server if you have access. 凯文(Kevin),如果您的服务器上未安装PHP SSH2扩展,那么最好的选择是在具有访问权限的其他服务器上设置公钥/私钥身份验证。 Then you can keep the private key on your PHP server, and pass -i on your scp command, something like this:
然后,您可以将私钥保留在PHP服务器上,并在scp命令中传递-i,如下所示:
scp -i /var/www/htdocs/myphpproject/rsakey filename username@server:filename
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.