This project is read-only.

SCP unexpected filename error

Apr 14, 2013 at 3:05 PM
I'm adding SCP functionality to a PowerShell module I wrote, Downloading I have 0 problems from Unix and Linux hosts but uploading I'm getting a unexpected filename error. My code is bellow
try
{
    //Ceate instance of SCP Client with connection info
    var Client = new ScpClient(connectInfo);

    // Connect to  host using Connection info
    Client.Connect();
    WriteVerbose("Connection succesfull");
    var localfullPath = Path.GetFullPath(localfile);
    if (File.Exists(localfullPath))
    {
        WriteVerbose("Uploading "+localfullPath);
        FileInfo fil = new FileInfo(@localfullPath);
        Client.Upload(File.OpenRead(@localfullPath),remotefile);

        Client.Disconnect();
    }
}
catch (Exception ex)
{
    throw ex;
}
Here is an example of the error:
C:\Users\Carlos> Set-SCPFile -ComputerName 192.168.1.154 -Credential (Get-Credential) -LocalFile .\bashist.txt -Rem
oteFile /etc/ssh/sshd_config.bak -Verbose

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
VERBOSE: Using Username and Password authentication for connection.
VERBOSE: Connecting to 192.168.1.154 with user root
VERBOSE: Connection succesfull
VERBOSE: Uploading C:\Users\Carlos\bashist.txt
Set-SCPFile : scp: error: unexpected filename: /etc/ssh/sshd_config.bak
At line:1 char:1
+ Set-SCPFile -ComputerName 192.168.1.154 -Credential (Get-Credential) -LocalFile  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-SCPFile], ScpException
    + FullyQualifiedErrorId : Renci.SshNet.Common.ScpException,SSH.Set_SCPFile
Any idea why I could be getting this error?