Search code examples
scp

SCP fails to authenticate due to backslash in username


I am using SCP to transfer a folder from a remote server (RS1) to another remote server (RS2). My command is:

scp PEM\username@RS1:/home/local/PEM/folderName1/ PEM\username@RS2:/home/local/PEM/foldername2

Final errors I get after putting the password for PEM\username is:

Permission denied, please try again
Permission denied, please try again
Received disconnect from RS2. Too many authentication failures for PEMusername

As you can see, the error message quotes PEMusername as my username and not PEM\username.

Is there a way to explicitly mention the username for SCP protocol?


Solution

  • The \ is an escape character in *nix shell.

    If you need to specify backslash explicitly, either double it:

    scp PEM\\username@RS1:/home/local/PEM/folderName1/ ...
    

    or wrap whole parameter to single-quotes:

    scp 'PEM\username@RS1:/home/local/PEM/folderName1/' ...