sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.94k stars 927 forks source link

ScpClient.Upload and Mikrotik #745

Open MVKozlov opened 3 years ago

MVKozlov commented 3 years ago

ScpClient.Upload do not work with mikrotik

I try to use latest beta with Renci.SshNet.RemotePathTransformation.None according to #255 and found that Upload do not work with mikrotik. There is also issue in Posh-SSH https://github.com/darkoperator/Posh-SSH/issues/349 My code is

Add-Type -Path D:\Renci.SshNet.dll
$client = [Renci.SshNet.ScpClient]::new($mikrotik_address, $mikrotik_port, $mikrotik_user, $mikrotik_password)
$client.connect()
$fi = [System.IO.FileInfo]::new('D:\Renci.SshNet.dll')
# There is a infinite hangup
$client.Upload($fi, 'file')

I tried to debug this problem and found that when I comment out UploadTimes(channel, input, file); https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/ScpClient.NET.cs#L196 It works Seems, mikrotik do not support UploadTimes at all. It creates file name with timestamp name Is there any method to disable times support for some connections except commenting it out and have customized library?

mittio commented 2 years ago

@MVKozlov , or anyone else, I too saw this issue with Mikrotik and scp. However, the SftpClient worked great. So that's at-least a workaround.