This project is read-only.

SCP from Juniper Devices failing.

Dec 5, 2012 at 6:10 PM

It appears the SCP service from Juniper devices does not support some of the command switches that are passed on default.

Is there a way to control the parameters without re-compiling the application?


When the SCP command is sent using PSCP this is what is present:

command=scp -f ns_sys_config

2012-12-05 10:03:44 system notif 00026 SCP: Admin user transferred file 'ns_sys_config' from device to host xxx.xxx.xxx.xxx.


When sent with the library ScpClient the following is sent:

command=scp -qf "ns_sys_config"

2012-12-05 10:35:04 system warn  00528 SCP: Admin at host xxx.xxx.xxx.xxx executed invalid scp command: 'scp -qf "ns_sys_config"'.


I'm not completely sure what the -q flag does, but its pretty evident that these devices don't support it.

 

Side note - this is my first post in the community but I want to give a shout out on the awesome work done on this library. It has really been helpful.

Dec 5, 2012 at 8:31 PM
Edited Dec 6, 2012 at 4:47 AM

Update:

I tried just making the flags on the internal SCP command into an optional argument...

in ScpClient.NET.cs:

public void Download(string filename, FileInfo fileInfo, string options = "-qpf")

 relevant change: channel.SendExecRequest(string.Format("scp {1} \"{0}\"", filename, options));

 

I also made a similar change in ScpClient.cs for the FileStream Download function.

No change in the result however.

## 2012-12-05 17:38:59 : SSH conn: >>> process_channel_request()
## 2012-12-05 17:38:59 : SSH conn: channel_id=566, request_type_name=exec, want_reply=1
## 2012-12-05 17:38:59 : SSH conn: command = scp -f "ns_sys_config"
## 2012-12-05 17:38:59 : SCP: >>> scp_create_session(command=scp -f "ns_sys_config")
## 2012-12-05 17:38:59 : SCP: <<< scp_create_session() = 0
## 2012-12-05 17:38:59 : SSH state trans: SSH_STATE_CONNECTING(9) -> SSH_STATE_DISCONNECTING(11)
## 2012-12-05 17:38:59 : SSH conn: <<< process_channel_request() = 0
## 2012-12-05 17:39:00 : SSH CONN:sending out exit status 1

Source Code Snippet:

[System.IO.FileStream]$fWriter = New-Object System.IO.FileStream($FullFilePath, [System.IO.FileMode]::OpenOrCreate, [System.IO.FileAccess]::ReadWrite);
$timeout = New-TimeSpan -Seconds 5
$global:LastSshSession.OperationTimeout = $timeout
$global:LastSshSession.BufferSize = (8 * 1024)
Debug-Message "Starting Download..."
$global:LastSshSession.Download("ns_sys_config", $fWriter, "-f")