f



PSCP does not copy file - "Cannot create file"

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.
0
Petr
11/22/2014 9:43:26 PM
comp.security.ssh 4228 articles. 0 followers. terra1024 (490) is leader. Post Follow

5 Replies
5860 Views

Similar Articles

[PageSpeed] 13

Petr Laznovsky  <nobody@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 <anakin@pobox.com>")
1
Simon
11/22/2014 11:45:31 PM
Dne 23.11.2014 0:45, Simon Tatham napsal(a):
> Petr Laznovsky  <nobody@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.

0
Petr
11/23/2014 10:07:16 AM
Petr Laznovsky <nobody@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).
0
Jacob
11/23/2014 1:05:45 PM
Dne 23.11.2014 14:05, Jacob Nevins napsal(a):
> Petr Laznovsky <nobody@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).
>

Oh I see, with Pre-release 0.64:2014-11-23.8c09f85 looks fine.

Thank you, P.L.
0
Petr
11/23/2014 8:21:31 PM
On Saturday, November 22, 2014 at 4:43:30 PM UTC-5, Petr Laznovsky 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\"
> 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.

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. 
0
siavashmonfared
2/1/2015 9:49:13 PM
Reply: