Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PSCP does not copy file - "Cannot create file"

11,355 views
Skip to first unread message

Petr Laznovsky

unread,
Nov 22, 2014, 4:43:30 PM11/22/14
to
Trying to backup config file from network box, but have no luck:

--------------------------------------------------------------
C:\>pscp.exe -scp -pw password -2 -v login@hostname:/tmp/system.cfg "E:\backup\krabky\configs\"
Looking up host "hostname"
Connecting to IP_address port 22
We claim version: SSH-2.0-PuTTY_Release_0.63
Server version: SSH-2.0-dropbear_0.51
Using SSH protocol version 2
Using Diffie-Hellman with standard group "group1"
Doing Diffie-Hellman key exchange with hash SHA-1
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
ssh-rsa 1040 c4:cd:93:ba:33:9c:97:49:39:54:0d:9a:a4:52:e6:7e
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n) n
Host key fingerprint is:
ssh-rsa 1040 c4:cd:93:ba:33:9c:97:49:39:54:0d:9a:a4:52:e6:7e
Initialised AES-256 CBC client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 CBC server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "login".
Sent password
Access granted
Opening session as main channel
Opened main channel
Started a shell/command
Using SCP1
Connected to hostname
Sending file modes: C0644 6297 system.cfg
pscp: E:\backup\krabky\configs": Cannot create file

Fatal: Received unexpected end-of-file from server

---------------------------------------------------------------

Thinking about insuficient access rights to destination location, but "echo AAA >
E:\backup\krabky\configs\file.txt" performed from same console window work fine. Where the problem
could be?

L.

Simon Tatham

unread,
Nov 22, 2014, 6:45:34 PM11/22/14
to
Petr Laznovsky <nob...@nowhere.com> wrote:
> Trying to backup config file from network box, but have no luck:
> --------------------------------------------------------------
> C:\>pscp.exe -scp -pw password -2 -v login@hostname:/tmp/system.cfg
> "E:\backup\krabky\configs\"
[...]
> pscp: E:\backup\krabky\configs": Cannot create file

My first thought about that error message is that the " at the end of
the filename is suspicious - it's not matched by one at the start of
the filename, which is a clue that perhaps it's not part of the format
of the error message but has instead found its way into the actual
filename string. That would certainly explain an error like that, if
the SSH server were trying to create a file whose name was a single "
character.

And in fact, having had that thought, it seems clear what's happened.
Your command line ends in \", which Windows's quoting rules probably
take to mean a literal " character (as opposed to one which terminates
a double-quoted string). So by the time PSCP even receives your
command line, it's already not saying what you wanted it to say.

Try taking those double quotes out of your command and see if that
helps.
--
import hashlib; print (lambda p,q,g,y,r,s,m: m if (lambda w:(pow(g,int(hashlib.
sha1(m).hexdigest(),16)*w%q,p)*pow(y,r*w%q,p)%p)%q)(pow(s,q-2,q))==r else "!"
)(0xb80b5dacabab6145, 0xf70027d345023, 0x7643bc4018957897, 0x11c2e5d9951130c9,
0xa54d9cbe4e8ab, 0x746c50eaa1910, "Simon Tatham <ana...@pobox.com>")

Petr Laznovsky

unread,
Nov 23, 2014, 5:07:18 AM11/23/14
to
Dne 23.11.2014 0:45, Simon Tatham napsal(a):
> Petr Laznovsky <nob...@nowhere.com> wrote:
>> Trying to backup config file from network box, but have no luck:
>> --------------------------------------------------------------
>> C:\>pscp.exe -scp -pw password -2 -v login@hostname:/tmp/system.cfg
>> "E:\backup\krabky\configs\"
> [...]
>> pscp: E:\backup\krabky\configs": Cannot create file
>
> My first thought about that error message is that the " at the end of
> the filename is suspicious - it's not matched by one at the start of
> the filename, which is a clue that perhaps it's not part of the format
> of the error message but has instead found its way into the actual
> filename string. That would certainly explain an error like that, if
> the SSH server were trying to create a file whose name was a single "
> character.
>
> And in fact, having had that thought, it seems clear what's happened.
> Your command line ends in \", which Windows's quoting rules probably
> take to mean a literal " character (as opposed to one which terminates
> a double-quoted string). So by the time PSCP even receives your
> command line, it's already not saying what you wanted it to say.
>
> Try taking those double quotes out of your command and see if that
> helps.
>

You are right, deleting last backslash fix the problem with "Cannot create file" and file is
successfully copied now. But the errormessage "Fatal: Received unexpected end-of-file from server"
remains even if I remowe doublequotes at all (my current path does not contain any space).

Notice that this message was not present with 0.62 version but arise after upgrade to 0.63 version.

L.

Jacob Nevins

unread,
Nov 23, 2014, 8:05:49 AM11/23/14
to
Petr Laznovsky <nob...@nowhere.com> writes:
>But the errormessage "Fatal: Received unexpected end-of-file from
>server" remains even if I remowe doublequotes at all (my current path
>does not contain any space).
>
>Notice that this message was not present with 0.62 version but arise
>after upgrade to 0.63 version.

That's probably due to a known bug in 0.63; it'll happen whenever you
download a file using the old-style SCP protocol (which you've forced
with the '-scp' option).

Petr Laznovsky

unread,
Nov 23, 2014, 3:21:33 PM11/23/14
to Jacob Nevins
Dne 23.11.2014 14:05, Jacob Nevins napsal(a):
Oh I see, with Pre-release 0.64:2014-11-23.8c09f85 looks fine.

Thank you, P.L.

siavash...@gmail.com

unread,
Feb 1, 2015, 4:49:14 PM2/1/15
to
Hi Simon - I have a similar question. I'm trying to copy a file from a remote server into my computer. This is the command i use:

pscp monfared@YYY:/home/monfared/XX.txt C:\Users\monfared\Xx.txt\.

The same line works when i use it to transfer files to my desktop computer but it gives me the "cannot create file" message when i use it to copy a file into my laptop. Any help/suggestions would be much appreciated.
Message has been deleted

mark.h...@gmail.com

unread,
Mar 15, 2017, 10:36:56 PM3/15/17
to
On Saturday, November 22, 2014 at 4:43:30 PM UTC-5, Petr Laznovsky wrote:
In my case the issue was that I was using a Unix style path to the cygwin /tmp directory, and apparently pscp only likes Windows paths. So I used cygpath to convert the unix path to the windows path.
0 new messages