15

I am trying to move a file from my local Windows machine to a remote Linux server using PSCP. I am connected to the VPN so that I can access my remote Linux machine with my username and password.

My PSCP command for transfer is:

pscp C:\Users\username\Desktop\list.txt PEM\username@10.120.43.78:/home/local/PEM/username

This result in the error

Local to local copy not supported


I have tried this command just for a trial

pscp C:\Users\username\Desktop\list.txt username@10.120.43.78:/home/local/PEM/username

The above command resulted in asking me the password. However, when I type in the password, the access is denied. This is because my remote Linux machine username is PEM/username and not username. However if I use PEM/username the "Local to local copy not supported" error message is coming. Does it have something to do with the slash \ in the username PEM\username?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
j1897
  • 1,507
  • 5
  • 21
  • 41

4 Answers4

20

Yes, it's the backslash.

To workaround it, use an -l switch to specify the username.

pscp -l PEM\username C:\Users\username\Desktop\list.txt 10.120.43.78:/home/local/PEM/username

Background:

The PSCP looks for the first colon, slash or backslash in the target. Only if the first symbol is colon, it considers the target as remote, otherwise as local.

/*
 *  Find a colon in str and return a pointer to the colon.
 *  This is used to separate hostname from filename.
 */
static char *colon(char *str)
{
    /* We ignore a leading colon, since the hostname cannot be
       empty. We also ignore a colon as second character because
       of filenames like f:myfile.txt. */
    if (str[0] == '\0' || str[0] == ':' ||
        (str[0] != '[' && str[1] == ':'))
    return (NULL);
    str += host_strcspn(str, ":/\\");
    if (*str == ':')
    return (str);
    else
    return (NULL);
}

...

if (colon(argv[argc - 1]) != NULL)
    toremote(argc, argv);
else
    tolocal(argc, argv);
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
0

I think you are missing a quote-mark after the Windows file path:

pscp "C:\Users\username\Desktop\list.txt" PEM\username@10.120.43.78:/home/local/PEM/username
iacob
  • 20,084
  • 6
  • 92
  • 119
anjalis
  • 397
  • 2
  • 19
  • Sorry, I did not miss the quotation marks. I have edited the typo in my question. In fact, you actually do not require quotation marks for PSCP. Thanks for your input though – j1897 Dec 02 '15 at 08:16
0

Another way is to try leaving space between the end of the file path when you type root @ your ip.

I had the same error

Wrong way

Correct way

0

In my case, I was executing the pscp command within a PowerShell v7 context, using environment variables to supply values for the computer IP, SSH User, SSH password, etc. The colon : that delimits the remote host IP and the remote path to copy the file to was being interpreted as a part of the variable for the computer IP. By wrapping this computer IP variable in $() I was able to run the command within my powershell script, and properly expand the variable without the delimiting colon being interpreted as part of the variable name.

Bad:

echo n | pscp.exe -pw $env:SSH_PW "$env:CI_PROJECT_DIR\prereq\prereq_test_join_domain.ps1" $env:SSH_USER@$env:TEST_COMPUTER_IP:C:/

Good:

echo n | pscp.exe -pw $env:SSH_PW "$env:CI_PROJECT_DIR\prereq\prereq_test_join_domain.ps1" $env:SSH_USER@$($env:TEST_COMPUTER_IP):C:/ 
rdo93
  • 1
  • 1