Error code 2 on SCP file from local to remote computer

Advertisement

OokInTheComputer
Joined:
Posts:
3
Location:
South Africa

Error code 2 on SCP file from local to remote computer

Good afternoon all
I have an issue with PowerShell and WinSCP.
Basically I have code which checks for replication on HyperV, then SCP the result to an SCP server.
So far the script works well, except when SCPing the file.

My code:
$transferResult =
$session.PutFiles("C:\Reports\*.htm", "/incoming/", $False, $transferOptions)
When the code is run, I get the following message :
Error: Exception calling "Check" with "0" argument(s): "Cannot create remote file '/incoming/FileName2022-01-12.htm'.
No such file or directory.
Error code: 2
Error message from server: No such file"
I have checked and verified that the SSH account do have write access to the specified account, and I have SCP'd successfully from another computer using Posh-SSH with the same account.

Thanking you for your assistance in this regard.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,587
Location:
Prague, Czechia

Re: Error code 2 on SCP file from local to remote computer

Is your account really chrooted? Shouldn't the path rather be like /home/user/incoming?
Can you upload the file using WinSCP GUI? If you can, have it generate a code template for you:
https://winscp.net/eng/docs/guide_automation#generating
If this does not help, post logs both from the GUI and the PowerShell.
See also Automate file transfers (or synchronization) to FTP server or SFTP server

Reply with quote

Advertisement

You can post new topics in this forum