public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* scp command fails to transfer file and returns 1.
@ 2022-07-13  7:41 suzuki.masaomi
  2022-07-13 14:38 ` Takashi Yano
  2022-07-16 14:10 ` Cyrille Lefevre
  0 siblings, 2 replies; 7+ messages in thread
From: suzuki.masaomi @ 2022-07-13  7:41 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'; +Cc: 'soft-mpop-qqm@ml.css.fujitsu.com'

Cygwinサポート ご担当様

お世話になっております。
沈 テイです。

下記の問題の解決について、ご協力をお願いします。

■環境
  OS: Windows Server 2019
 Cygwinバージョン: 3.3.5

■問題が起きた背景
 当方のアプリケーションプログラムでは、リモートシステム(OS: Linux)へ
 SSH通信やファイル転送を行う目的で、Cygwinに含まれるssh, scpコマンドを
 子プロセスとして実行する実装にしています。
 ※実証内容の詳細は、"■当方のアプリケーションプログラム"を参照
 ※事前準備として、SSH公開鍵を設定し、パスワードの問い合わせ無しで
  SSH接続できることを確認しています。

■問題の内容
 URL(https://www.cygwin.com/)からダウンロードした最新バージョン(3.3.5)の
 CygwinをOSに導入した後、当方のアプリケーションプログラムを実行すると、
 scpコマンドは毎回、戻り値"1"で復帰し、ファイル転送が失敗します。

 当方のアプリケーションプログラムをデバックした結果、
 scpコマンドは下記のメッセージを返却していました。

 /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
 /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"

■問題の補足
 ・scpコマンドを、当方のアプリケーションプログラムから子プロセスとして
  実行するのではなく、コマンドプロンプトやCygwin Bash Shellから直接的に
  実行した場合は、戻り値"0"で復帰し、ファイル転送は成功します。

 ・旧バージョン(3.2.0)のCygwinを同じOSに導入した後、
  当方のアプリケーションプログラムを実行した場合は、scpコマンドは
  戻り値"0"で復帰し、ファイル転送は成功します。

 以上のことから、我々は、最新バージョン(3.3.5)と旧バージョン(3.2.0)の
 Cygwinで、scpコマンドの動作仕様に何らかの非互換があるのではないか、と
 推測しています。

■依頼事項
 上記の問題に対して、考えられる原因および対処方法はありますか?

  <回答先>
  soft-mpop-qqm@ml.css.fujitsu.com

■当方のアプリケーションプログラム
 ・子プロセスの実行方法
  Windows APIのCreateProcess()を以下の様に使用し、子プロセスを実行します。

  CreateProcess(NULL, 
        fullPathCmd,  /* ssh,scpのcommond line                     */
        NULL,           /* process security attributes              */
        NULL,           /* primary thread security attributes       */
        TRUE,           /* handles are inherited                    */
        NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,  /* creation flags  */
        NULL,           /* use parent's environment                 */
        NULL,           /* use parent's current directory           */
        &si,            /* STARTUPINFO pointer                      */
        &pi);           /* receives PROCESS_INFORMATION             */

 ・sshコマンドを実行する時のコマンドライン
  上記に示したCreateProcess()の第2パラメタfullPathCmdを、以下の様に
  指定しています。

  <Cygwinのインストールディレクトリ>\bin\ssh.exe -q -l root -p 22 ホスト名 "echo aaa && /bin/sh -c \"/bin/uname -n\""

 ・scpコマンドを実行する時のコマンドライン
  上記に示したCreateProcess()の第2パラメタfullPathCmdを、以下の様に
  指定しています。
  
  <Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:""/tmp/a""


以上、よろしくお願いします。


以降は英訳文章です。
******************************************************************
Cygwin Support Dear Representatives

Thank you for your support.
I am Shen Ting.

We ask for your cooperation in solving the following problem.

■Environment
  OS: Windows Server 2019
 Cygwin Version : 3.3.5

■Background of the problem
In our application program, for the purpose of SSH communication and file transfer to a remote system (OS: Linux), 
the ssh and scp commands included in Cygwin are executed as child processes.
(*) For details of the demonstration contents, refer to "■Our Application Program"
(*)As a preliminary preparation, we set the SSH public key and 
   confirm that we can connect to SSH without inquiring about the password.

■The problem
In the OS, after installing the latest version (3.3.5) of Cygwin downloaded from the URL(https://www.cygwin.com/), 
when we execute our application program, the scp command returns "1" every time, and the file transfer fails.

As a result of debugging our application program, the scp command returned the following message.

 /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
 /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"

■Problem supplement
・If the scp command is executed directly from the command prompt or Cygwin Bash Shell
  instead of being executed from our application program as a child process, 
  "0" will be returned and the file transfer will succeed.

・If we execute our application program after introducing the old version Cygwin(3.2.0) to the same OS, 
  the scp command will return "0" and the file transfer will be successful.

From the above, we speculate that there may be some incompatibility in the operating specifications of 
the scp command in the latest version Cygwin(3.3.5) and the old version Cygwin(3.2.0).

■Requests
  Are there any possible causes and workarounds for the above problem?

  <Respondents>
   soft-mpop-qqm@ml.css.fujitsu.com

■Our Application Program
・How child processes run
  Use the Windows API CreateProcess() as follows to execute the child process.

  CreateProcess(NULL, 
        fullPathCmd,  /* ssh,scpのcommond line                    */
        NULL,           /* process security attributes              */
        NULL,           /* primary thread security attributes       */
        TRUE,           /* handles are inherited                    */
        NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,  /* creation flags  */
        NULL,           /* use parent's environment                 */
        NULL,           /* use parent's current directory           */
        &si,            /* STARTUPINFO pointer                      */
        &pi);           /* receives PROCESS_INFORMATION             */

・Command line when executing ssh command
  The second parameter of CreateProcess() shown above, fullPathCmd, is specified as follows.
 
   <Cygwin Installation Directory>\bin\ssh.exe -q -l root -p 22 ホスト名 "echo aaa && /bin/sh -c \"/bin/uname -n\""

・Command line when executing scp command
  The second parameter of CreateProcess() shown above, fullPathCmd, is specified as follows.
 
   <Cygwin Installation Directory>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:""/tmp/a""

******************************************************************

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scp command fails to transfer file and returns 1.
  2022-07-13  7:41 scp command fails to transfer file and returns 1 suzuki.masaomi
@ 2022-07-13 14:38 ` Takashi Yano
  2022-07-16 14:10 ` Cyrille Lefevre
  1 sibling, 0 replies; 7+ messages in thread
From: Takashi Yano @ 2022-07-13 14:38 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'
  Cc: suzuki.masaomi, 'soft-mpop-qqm@ml.css.fujitsu.com'

On Wed, 13 Jul 2022 07:41:25 +0000
> Cygwinサポート ご担当様
> 
> お世話になっております。
> 沈 テイです。
> 
> 下記の問題の解決について、ご協力をお願いします。
> 
> ■環境
>   OS: Windows Server 2019
>  Cygwinバージョン: 3.3.5
> 
> ■問題が起きた背景
>  当方のアプリケーションプログラムでは、リモートシステム(OS: Linux)へ
>  SSH通信やファイル転送を行う目的で、Cygwinに含まれるssh, scpコマンドを
>  子プロセスとして実行する実装にしています。
>  ※実証内容の詳細は、"■当方のアプリケーションプログラム"を参照
>  ※事前準備として、SSH公開鍵を設定し、パスワードの問い合わせ無しで
>   SSH接続できることを確認しています。
> 
> ■問題の内容
>  URL(https://www.cygwin.com/)からダウンロードした最新バージョン(3.3.5)の
>  CygwinをOSに導入した後、当方のアプリケーションプログラムを実行すると、
>  scpコマンドは毎回、戻り値"1"で復帰し、ファイル転送が失敗します。
> 
>  当方のアプリケーションプログラムをデバックした結果、
>  scpコマンドは下記のメッセージを返却していました。
> 
>  /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
>  /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"
> 
> ■問題の補足
>  ・scpコマンドを、当方のアプリケーションプログラムから子プロセスとして
>   実行するのではなく、コマンドプロンプトやCygwin Bash Shellから直接的に
>   実行した場合は、戻り値"0"で復帰し、ファイル転送は成功します。
> 
>  ・旧バージョン(3.2.0)のCygwinを同じOSに導入した後、
>   当方のアプリケーションプログラムを実行した場合は、scpコマンドは
>   戻り値"0"で復帰し、ファイル転送は成功します。
> 
>  以上のことから、我々は、最新バージョン(3.3.5)と旧バージョン(3.2.0)の
>  Cygwinで、scpコマンドの動作仕様に何らかの非互換があるのではないか、と
>  推測しています。
> 
> ■依頼事項
>  上記の問題に対して、考えられる原因および対処方法はありますか?
> 
>   <回答先>
>   soft-mpop-qqm@ml.css.fujitsu.com
> 
> ■当方のアプリケーションプログラム
>  ・子プロセスの実行方法
>   Windows APIのCreateProcess()を以下の様に使用し、子プロセスを実行します。
> 
>   CreateProcess(NULL, 
>         fullPathCmd,  /* ssh,scpのcommond line                     */
>         NULL,           /* process security attributes              */
>         NULL,           /* primary thread security attributes       */
>         TRUE,           /* handles are inherited                    */
>         NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,  /* creation flags  */
>         NULL,           /* use parent's environment                 */
>         NULL,           /* use parent's current directory           */
>         &si,            /* STARTUPINFO pointer                      */
>         &pi);           /* receives PROCESS_INFORMATION             */
> 
>  ・sshコマンドを実行する時のコマンドライン
>   上記に示したCreateProcess()の第2パラメタfullPathCmdを、以下の様に
>   指定しています。
> 
>   <Cygwinのインストールディレクトリ>\bin\ssh.exe -q -l root -p 22 ホスト名 "echo aaa && /bin/sh -c \"/bin/uname -n\""
> 
>  ・scpコマンドを実行する時のコマンドライン
>   上記に示したCreateProcess()の第2パラメタfullPathCmdを、以下の様に
>   指定しています。
>   
>   <Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:""/tmp/a""
> 
> 
> 以上、よろしくお願いします。
> 
> 
> 以降は英訳文章です。
> ******************************************************************
> Cygwin Support Dear Representatives
> 
> Thank you for your support.
> I am Shen Ting.
> 
> We ask for your cooperation in solving the following problem.
> 
> ■Environment
>   OS: Windows Server 2019
>  Cygwin Version : 3.3.5
> 
> ■Background of the problem
> In our application program, for the purpose of SSH communication and file transfer to a remote system (OS: Linux), 
> the ssh and scp commands included in Cygwin are executed as child processes.
> (*) For details of the demonstration contents, refer to "■Our Application Program"
> (*)As a preliminary preparation, we set the SSH public key and 
>    confirm that we can connect to SSH without inquiring about the password.
> 
> ■The problem
> In the OS, after installing the latest version (3.3.5) of Cygwin downloaded from the URL(https://www.cygwin.com/), 
> when we execute our application program, the scp command returns "1" every time, and the file transfer fails.
> 
> As a result of debugging our application program, the scp command returned the following message.
> 
>  /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
>  /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"
> 
> ■Problem supplement
> ・If the scp command is executed directly from the command prompt or Cygwin Bash Shell
>   instead of being executed from our application program as a child process, 
>   "0" will be returned and the file transfer will succeed.
> 
> ・If we execute our application program after introducing the old version Cygwin(3.2.0) to the same OS, 
>   the scp command will return "0" and the file transfer will be successful.
> 
> From the above, we speculate that there may be some incompatibility in the operating specifications of 
> the scp command in the latest version Cygwin(3.3.5) and the old version Cygwin(3.2.0).
> 
> ■Requests
>   Are there any possible causes and workarounds for the above problem?
> 
>   <Respondents>
>    soft-mpop-qqm@ml.css.fujitsu.com
> 
> ■Our Application Program
> ・How child processes run
>   Use the Windows API CreateProcess() as follows to execute the child process.
> 
>   CreateProcess(NULL, 
>         fullPathCmd,  /* ssh,scpのcommond line                    */
>         NULL,           /* process security attributes              */
>         NULL,           /* primary thread security attributes       */
>         TRUE,           /* handles are inherited                    */
>         NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,  /* creation flags  */
>         NULL,           /* use parent's environment                 */
>         NULL,           /* use parent's current directory           */
>         &si,            /* STARTUPINFO pointer                      */
>         &pi);           /* receives PROCESS_INFORMATION             */
> 
> ・Command line when executing ssh command
>   The second parameter of CreateProcess() shown above, fullPathCmd, is specified as follows.
>  
>    <Cygwin Installation Directory>\bin\ssh.exe -q -l root -p 22 ホスト名 "echo aaa && /bin/sh -c \"/bin/uname -n\""
> 
> ・Command line when executing scp command
>   The second parameter of CreateProcess() shown above, fullPathCmd, is specified as follows.
>  
>    <Cygwin Installation Directory>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:""/tmp/a""

I cannot reproduce your problem. Could you please provide
simple test case in C-lang?


-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: scp command fails to transfer file and returns 1.
  2022-07-13  7:41 scp command fails to transfer file and returns 1 suzuki.masaomi
  2022-07-13 14:38 ` Takashi Yano
@ 2022-07-16 14:10 ` Cyrille Lefevre
  2022-07-19  2:40   ` [soft-mpop-qqm:27201] " suzuki.masaomi
  1 sibling, 1 reply; 7+ messages in thread
From: Cyrille Lefevre @ 2022-07-16 14:10 UTC (permalink / raw)
  To: suzuki.masaomi, 'cygwin@cygwin.com'
  Cc: 'soft-mpop-qqm@ml.css.fujitsu.com'

Le 13/07/2022 à 09:41, suzuki.masaomi@fujitsu.com a écrit :
> As a result of debugging our application program, the scp command returned the following message.
> 
>  /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
>  /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"

Hi,

it seems your application is calling scp with " around the arguments, 
so, scp try to copy "/tmp/a" instead of just /tmp/a.

Regards,

/me
-- 
mailto:Cyrille.Lefevre-lists@laposte.net


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [soft-mpop-qqm:27201] Re: scp command fails to transfer file and returns 1.
  2022-07-16 14:10 ` Cyrille Lefevre
@ 2022-07-19  2:40   ` suzuki.masaomi
  2022-07-19  4:18     ` Takashi Yano
  0 siblings, 1 reply; 7+ messages in thread
From: suzuki.masaomi @ 2022-07-19  2:40 UTC (permalink / raw)
  To: 'cyrille.lefevre-lists@laposte.net', 'cygwin@cygwin.com'
  Cc: 'soft-mpop-qqm@ml.css.fujitsu.com'

Cygwin Support Dear Representatives

Thank you very much for your reply.

>it seems your application is calling scp with " around the arguments, so, scp try to copy "/tmp/a" instead of just /tmp/a.

We analyzed our application again, internally, calling scp command is as follows.

 <Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""

The scp command above runs successfully with the old version Cygwin(3.2.0),
but not with the the latest version Cygwin(3.3.5). 

<result of execution on command prompt>
=============================================
●the old version Cygwin(3.2.0)
---------------------------------
C:\Users\Administrator>C:\cygwin64\bin\scp.exe "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
a                                                               100%   36KB   1.3MB/s   00:00

>echo %errorlevel%
0
---------------------------------
 →Successfully.

●the latest version Cygwin(3.3.5)
---------------------------------
C:\Users\Administrator>C:\cygwin64\bin\scp.exe "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
scp: dest open ""/tmp/a"": No such file or directory
scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"

>echo %errorlevel%
1
---------------------------------
 →Same error message as the scp command executed by our application.
=============================================
(*)execution on the Cygwin Bash Shell gets the same results.

Therefore, the arguments of the scp command are the same, 
but execution in the latest version Cygwin(3.3.5) has failed.
Can you tell me the reason why the execution results are different 
depending on the version of Cygwin?

Since the same problem occurs when execute the scp command 
on the command prompt or Cygwin Bash Shell,
I don't think sample program is needed anymore.



以降は日本語の文章です。
******************************************************************
Cygwinサポート ご担当様

ご協力、どうもありがとうございました。

>it seems your application is calling scp with " around the arguments, so, scp try to copy "/tmp/a" instead of just /tmp/a.

当方のアプリケーションプログラムを再度確認して、
内部的には下記のようにscpコマンドを実行しています。

 <Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""

上記のscpコマンドは、旧バージョン(3.2.0)のCygwinでは正常に行われていますが、
最新バージョン(3.3.5)では正常に行われていません。

<コマンドプロンプトでの実行結果>
=============================================
●旧バージョン(3.2.0)のCygwin
---------------------------------
C:\Users\Administrator>C:\cygwin64\bin\scp.exe "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
a                                                               100%   36KB   1.3MB/s   00:00

>echo %errorlevel%
0
---------------------------------
 →正常に行われています。

●最新バージョン(3.3.5)のCygwin
---------------------------------
C:\Users\Administrator>C:\cygwin64\bin\scp.exe "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
scp: dest open ""/tmp/a"": No such file or directory
scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"

>echo %errorlevel%
1
---------------------------------
 →アプリケーションにより実行したscpコマンドと同じエラーメッセージです。
=============================================
※Cygwin Bash Shellから実行したら同じ結果です。

よって、scpコマンドの引数が同じですが、最新バージョン(3.3.5)のCygwinでの
実行が失敗しています。
上記の様に、Cygwinのバージョンによって実行結果が異なる理由を
教えていただけませんでしょうか。

また、コマンドプロンプトやCygwin Bash Shellで、同じ現象が発生したため、
サンプルプログラムが不要だと思います。
******************************************************************

> -----Original Message-----
> From: Cyrille Lefevre <cyrille.lefevre-lists@laposte.net>
> Sent: Saturday, July 16, 2022 11:10 PM
> To: Suzuki, Masaomi/鈴木 将臣 <suzuki.masaomi@fujitsu.com>;
> 'cygwin@cygwin.com' <cygwin@cygwin.com>
> Cc: 'soft-mpop-qqm@ml.css.fujitsu.com'
> <soft-mpop-qqm@ml.css.fujitsu.com>
> Subject: [soft-mpop-qqm:27201] Re: scp command fails to transfer file and
> returns 1.
> 
> Le 13/07/2022 à 09:41, suzuki.masaomi@fujitsu.com a écrit :
> > As a result of debugging our application program, the scp command returned
> the following message.
> >
> >  /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
> >  /usr/bin/scp: failed to upload file /cygdrive//C/test/a to "/tmp/a"
> 
> Hi,
> 
> it seems your application is calling scp with " around the arguments, so, scp try
> to copy "/tmp/a" instead of just /tmp/a.
> 
> Regards,
> 
> /me
> --
> mailto:Cyrille.Lefevre-lists@laposte.net


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [soft-mpop-qqm:27201] Re: scp command fails to transfer file and returns 1.
  2022-07-19  2:40   ` [soft-mpop-qqm:27201] " suzuki.masaomi
@ 2022-07-19  4:18     ` Takashi Yano
  2022-07-19  4:53       ` Takashi Yano
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Yano @ 2022-07-19  4:18 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'
  Cc: suzuki.masaomi, 'soft-mpop-qqm@ml.css.fujitsu.com'

On Tue, 19 Jul 2022 02:40:14 +0000
> Thank you very much for your reply.
> 
> >it seems your application is calling scp with " around the arguments, so, scp try to copy "/tmp/a" instead of just /tmp/a.
> 
> We analyzed our application again, internally, calling scp command is as follows.
> 
>  <Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""
> 
> The scp command above runs successfully with the old version Cygwin(3.2.0),
> but not with the the latest version Cygwin(3.3.5). 
> 
> <result of execution on command prompt>
> =============================================
> ●the old version Cygwin(3.2.0)
> ---------------------------------
> C:\Users\Administrator>C:\cygwin64\bin\scp.exe "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
> a                                                               100%   36KB   1.3MB/s   00:00
> 
> >echo %errorlevel%
> 0
> ---------------------------------
>  →Successfully.

In my environment, your test case also fails with cygwin 3.2.0.

C:\Users\yano>\cygwin64\bin\uname -a
CYGWIN_NT-10.0-19044 HP-Z230 3.2.0-340.x86_64 2021-03-29 08:42 UTC x86_64 Cygwin

C:\Users\yano>\cygwin64\bin\scp "/home/yano/a" "yano"@server:"\"/tmp/a\""
/usr/bin/scp: dest open ""/tmp/a"": No such file or directory
/usr/bin/scp: failed to upload file /tmp/a to "/tmp/a"

The behaviour difference seems not due to cygwin version.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [soft-mpop-qqm:27201] Re: scp command fails to transfer file and returns 1.
  2022-07-19  4:18     ` Takashi Yano
@ 2022-07-19  4:53       ` Takashi Yano
  2022-07-20  1:42         ` suzuki.masaomi
  0 siblings, 1 reply; 7+ messages in thread
From: Takashi Yano @ 2022-07-19  4:53 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'
  Cc: suzuki.masaomi, 'soft-mpop-qqm@ml.css.fujitsu.com'

On Tue, 19 Jul 2022 13:18:55 +0900
Takashi Yano <takashi.yano@nifty.ne.jp> wrote:

> On Tue, 19 Jul 2022 02:40:14 +0000
> > Thank you very much for your reply.
> > 
> > >it seems your application is calling scp with " around the arguments, so, scp try to copy "/tmp/a" instead of just /tmp/a.
> > 
> > We analyzed our application again, internally, calling scp command is as follows.
> > 
> >  <Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""
> > 
> > The scp command above runs successfully with the old version Cygwin(3.2.0),
> > but not with the the latest version Cygwin(3.3.5). 
> > 
> > <result of execution on command prompt>
> > =============================================
> > ●the old version Cygwin(3.2.0)
> > ---------------------------------
> > C:\Users\Administrator>C:\cygwin64\bin\scp.exe "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
> > a                                                               100%   36KB   1.3MB/s   00:00
> > 
> > >echo %errorlevel%
> > 0
> > ---------------------------------
> >  →Successfully.
> 
> In my environment, your test case also fails with cygwin 3.2.0.
> 
> C:\Users\yano>\cygwin64\bin\uname -a
> CYGWIN_NT-10.0-19044 HP-Z230 3.2.0-340.x86_64 2021-03-29 08:42 UTC x86_64 Cygwin
> 
> C:\Users\yano>\cygwin64\bin\scp "/home/yano/a" "yano"@server:"\"/tmp/a\""
> /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
> /usr/bin/scp: failed to upload file /tmp/a to "/tmp/a"
> 
> The behaviour difference seems not due to cygwin version.

This seems to be behaviour change betweeen OpenSSH 8.x and 9.0.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [soft-mpop-qqm:27201] Re: scp command fails to transfer file and returns 1.
  2022-07-19  4:53       ` Takashi Yano
@ 2022-07-20  1:42         ` suzuki.masaomi
  0 siblings, 0 replies; 7+ messages in thread
From: suzuki.masaomi @ 2022-07-20  1:42 UTC (permalink / raw)
  To: 'Takashi Yano', 'cygwin@cygwin.com'
  Cc: 'soft-mpop-qqm@ml.css.fujitsu.com'

Cygwin Support Dear Representatives

Thank you very much for your reply.

>This seems to be behaviour change betweeen OpenSSH 8.x and 9.0.

You are right.

Referring to the URL below, the problem is caused by the change in the protocol 
used by the scp command by default in the latest OpenSSH (9.0p1-1).

https://www.openssh.com/releasenotes.html#9.0p1
---------------------------------
This release switches scp(1) from using the legacy scp/rcp protocol
to using the SFTP protocol by default.

Legacy scp/rcp performs wildcard expansion of remote filenames (e.g.
"scp host:* .") through the remote shell. This has the side effect of
requiring double quoting of shell meta-characters in file names
included on scp(1) command-lines, otherwise they could be interpreted
as shell commands on the remote side.

This creates one area of potential incompatibility: scp(1) when using
the SFTP protocol no longer requires this finicky and brittle quoting,
and attempts to use it may cause transfers to fail. We consider the
removal of the need for double-quoting shell characters in file names
to be a benefit and do not intend to introduce bug-compatibility for
legacy scp/rcp in scp(1) when using the SFTP protocol.

Another area of potential incompatibility relates to the use of remote
paths relative to other user's home directories, for example -
"scp host:~user/file /tmp". The SFTP protocol has no native way to
expand a ~user path. However, sftp-server(8) in OpenSSH 8.7 and later
support a protocol extension "expand-path@openssh.com" to support
this.

In case of incompatibility, the scp(1) client may be instructed to use
the legacy scp/rcp using the -O flag.(★)
---------------------------------

According to the above instructions(the ★ part), in the OpenSSH(9.0p1-1),
when runing the scp commond with -O option, the old protocol(legacy scp/rcp) will be used.

Therefore, I runed the scp command wit the -O option and it was successful.
---------------------------------
C:\Users\Administrator>C:\cygwin64\bin\scp.exe -O "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
a                                                               100%   36KB   1.3MB/s   00:00

>echo %errorlevel%
0
---------------------------------

Previously, in the old version Cygwin(3.2.0) that we downloaded from the URL (https://www.cygwin.com/), 
the version of OpenSSH is 8.4p1-1, so on our Windows that the Cygwin(3.2.0) was installed,
the following scp command can be successful.
---------------------------------
<Cygwin Installation Directory>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""
---------------------------------

The problem is not related to the version of Cygwin, I'm sorry to have troubled you.


以降は日本語の文章です。
******************************************************************
Cygwinサポート ご担当様

ご協力、どうもありがとうございました。

>This seems to be behaviour change betweeen OpenSSH 8.x and 9.0.

ご認識のとおりです。

下記のURLを参照したところ、今回の現象は、最新のOpenSSH(9.0p1-1)において、
scpコマンドがデフォルトで使用しているプロトコルの変更に起因していることがわかりました。

https://www.openssh.com/releasenotes.html#9.0p1
---------------------------------
This release switches scp(1) from using the legacy scp/rcp protocol
to using the SFTP protocol by default.

Legacy scp/rcp performs wildcard expansion of remote filenames (e.g.
"scp host:* .") through the remote shell. This has the side effect of
requiring double quoting of shell meta-characters in file names
included on scp(1) command-lines, otherwise they could be interpreted
as shell commands on the remote side.

This creates one area of potential incompatibility: scp(1) when using
the SFTP protocol no longer requires this finicky and brittle quoting,
and attempts to use it may cause transfers to fail. We consider the
removal of the need for double-quoting shell characters in file names
to be a benefit and do not intend to introduce bug-compatibility for
legacy scp/rcp in scp(1) when using the SFTP protocol.

Another area of potential incompatibility relates to the use of remote
paths relative to other user's home directories, for example -
"scp host:~user/file /tmp". The SFTP protocol has no native way to
expand a ~user path. However, sftp-server(8) in OpenSSH 8.7 and later
support a protocol extension "expand-path@openssh.com" to support
this.

In case of incompatibility, the scp(1) client may be instructed to use
the legacy scp/rcp using the -O flag.(★)
---------------------------------

上記の★箇所の説明により、OpenSSH(9.0p1-1)では、
-Oオプションを指定するscpコマンドを実行した場合、古いプロトコル(scp/rcp)が
使用されて、今回のscpコマンドが正常に行われると考えられます。

また、実機で-Oオプションを指定するscpコマンドを実行したところ、
正常に行われていることを確認しました。
---------------------------------
C:\Users\Administrator>C:\cygwin64\bin\scp.exe -O "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
a                                                               100%   36KB   1.3MB/s   00:00

>echo %errorlevel%
0
---------------------------------
※Cygwin Bash Shellにも正常に行われています。

過去に、当方がURL(https://www.cygwin.com/)からダウンロードした
旧バージョン(3.2.0)のCygwinにおいて、使用しているOpenSSHのバージョンが8.4p1-1 なので、
該当Cygwinが導入したWinodwsにて、下記のscpコマンドが正常に行われています。
---------------------------------
<Cygwinのインストールディレクトリ>\bin\scp.exe "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""
---------------------------------

今回の現象は、Cygwinのバージョンと関係していないため、
ご迷惑をおかけて、申し訳ございません。
******************************************************************

> -----Original Message-----
> From: Takashi Yano <takashi.yano@nifty.ne.jp>
> Sent: Tuesday, July 19, 2022 1:54 PM
> To: 'cygwin@cygwin.com' <cygwin@cygwin.com>
> Cc: Suzuki, Masaomi/鈴木 将臣 <suzuki.masaomi@fujitsu.com>;
> 'soft-mpop-qqm@ml.css.fujitsu.com' <soft-mpop-qqm@ml.css.fujitsu.com>
> Subject: Re: [soft-mpop-qqm:27201] Re: scp command fails to transfer file and
> returns 1.
> 
> On Tue, 19 Jul 2022 13:18:55 +0900
> Takashi Yano <takashi.yano@nifty.ne.jp> wrote:
> 
> > On Tue, 19 Jul 2022 02:40:14 +0000
> > > Thank you very much for your reply.
> > >
> > > >it seems your application is calling scp with " around the arguments, so,
> scp try to copy "/tmp/a" instead of just /tmp/a.
> > >
> > > We analyzed our application again, internally, calling scp command is as
> follows.
> > >
> > >  <Cygwinのインストールディレクトリ>\bin\scp.exe
> "/cygdrive//C/test/a" "root"@ホスト名:"\"/tmp/a\""
> > >
> > > The scp command above runs successfully with the old version
> > > Cygwin(3.2.0), but not with the the latest version Cygwin(3.3.5).
> > >
> > > <result of execution on command prompt>
> > > =============================================
> > > ●the old version Cygwin(3.2.0)
> > > ---------------------------------
> > > C:\Users\Administrator>C:\cygwin64\bin\scp.exe
> "/cygdrive//C/test/a" "root"@RJEL74JP:"\"/tmp/a\""
> > > a                                                               100%
> 36KB   1.3MB/s   00:00
> > >
> > > >echo %errorlevel%
> > > 0
> > > ---------------------------------
> > >  →Successfully.
> >
> > In my environment, your test case also fails with cygwin 3.2.0.
> >
> > C:\Users\yano>\cygwin64\bin\uname -a
> > CYGWIN_NT-10.0-19044 HP-Z230 3.2.0-340.x86_64 2021-03-29 08:42 UTC
> > x86_64 Cygwin
> >
> > C:\Users\yano>\cygwin64\bin\scp "/home/yano/a"
> "yano"@server:"\"/tmp/a\""
> > /usr/bin/scp: dest open ""/tmp/a"": No such file or directory
> > /usr/bin/scp: failed to upload file /tmp/a to "/tmp/a"
> >
> > The behaviour difference seems not due to cygwin version.
> 
> This seems to be behaviour change betweeen OpenSSH 8.x and 9.0.
> 
> --
> Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-20  1:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13  7:41 scp command fails to transfer file and returns 1 suzuki.masaomi
2022-07-13 14:38 ` Takashi Yano
2022-07-16 14:10 ` Cyrille Lefevre
2022-07-19  2:40   ` [soft-mpop-qqm:27201] " suzuki.masaomi
2022-07-19  4:18     ` Takashi Yano
2022-07-19  4:53       ` Takashi Yano
2022-07-20  1:42         ` suzuki.masaomi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).