ssh – How to Escape Backslash in ssh-copy-id

escape-charactersopensshssh

I'm connected to Ubuntu server that is a member of a corporate Active Directory domain via likewise-open. The users are in the form mydomain\myuser. I can connect to it via ssh, escaping the \ with another \:

ssh mydomain\\myuser@myserver

I've generated a pair of keys via ssh-keygen, then tried to copy it to the remote machine. The user I'm using in the local machine is not the same I want to copy the key into, so I issued the command:

ssh-copy-id mydomain\\myuser@myserver

and the output:

password:
password:
password:
mydomainyuser@myserver's password:
Received disconnect from myserver: 2: Too many authentication failures for myuserydomain

prompting me for the local user's password three times, and then the \\ actually worked as a single \ escaping the first m in mydomain. Am I getting this straight? And how can I escape that \ and correctly copy key to the remote machine?

EDIT: also ssh-copy-id myuser@mydomain.com@myserver turned out to be a valid syntax.. However, the question was about escaping the \.

Best Answer

The reason this is happening is because you are escaping it for the shell, but ssh-copy-id is also attempting to interpret it. This should work:

ssh-copy-id 'mydomain\\myuser@myserver'
Related Question