-
-
Notifications
You must be signed in to change notification settings - Fork 969
Description
Hi, and thanks for SSH.NET 👋
I’m using SSH.NET 2025.1.0 (via NuGet) and ran into the same Cisco SCP issue as described in #829 (“Scp on cisco device not working”).
On Cisco devices, the -d option used by ScpClient for uploads is not supported by their SCP implementation. In #829 this shows up as errors like:
-p -d options not supported
When I look at the 2025.1.0 source for ScpClient, I still see scp -t -d ... being used for uploads.
Example usage:
using var scp = new ScpClient(host, username, password);
scp.RemotePathTransformation = RemotePathTransformation.None;
scp.Connect();
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
scp.Upload(stream, "startup-config");
This works fine with OpenSSH servers but fails against Cisco devices due to the -d flag.
Request / proposal
For better interoperability, it would be helpful if ScpClient:
either removed -d for file uploads and just used
scp -t
or exposed a property to disable -d, e.g.:
public bool UseDirectoryFlag { get; set; } = true;
and then:
var target = _remotePathTransformation.Transform(UseDirectoryFlag ? posixPath.Directory : posixPath.File);
var exec = UseDirectoryFlag
? $"scp -t -d {target}"
: $"scp -t {target}";
if (!channel.SendExecRequest(exec))
{
throw SecureExecutionRequestRejectedException();
}
That would keep current behavior for OpenSSH, but allow users to work with Cisco and other limited SCP implementations without maintaining a custom fork.
Happy to help test any change against Cisco devices if needed.