我在将文件从我的laravel项目复制到另一台服务器时遇到问题。这就是我正在做的。SSH2我做错了什么?
$connection = ssh2_connect($this->ftpHostname, $this->ftpPort);
if (!$connection) {
throw new \Exception("Couldn't connect to {$this->ftpHostname}:{$this->ftpPort}");
}
$loginResult = ssh2_auth_password($connection, 'usrname', 'pswrd');
if (!$loginResult) {
throw new \Exception("Username or Password not accepted for {$this->ftpHostname}:{$this->ftpPort}");
}
$sftp = ssh2_sftp($connection);
$fullFilePath = storage_path() .'/'.$this->argument('local-file');
$remoteFilePath = "ssh2.sftp://{$sftp}/{$this->argument('remote-folder')}/SomeFolder/{$this->argument('remote-filename')}.txt";
$copyResult = copy($fullFilePath, $remoteFilePath);
但它给我这个错误
[ErrorException]
copy(): Unable to open ssh2.sftp://Resource id #621/My Folders/Upload only/sample.txt on remote host
我真的很新的SSH我该如何解决这个问题?
我使用的是ssh2,这就是我所知道的@ThomasMoors –
它是否正常返回? ssh2.sftp://资源ID#621 因为我混淆了错误的地方 –