Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scp on OSX doesn't allow spaces in usernames?

I need to ssh into a Windows 7 box running MobaSSH as its SSH daemon, and the username on the Windows box contains a space. I can login to the Windows 7 box on an OSX terminal like so:

ssh "Some User"@WindowsHost

So I thought I'd be able to use the scp command on OSX to transfer files between the computers, but I keep getting an error saying "invalid username" whenever I do something like this:

scp myfile "Some User"@WindowsHost:~/myfile

I looked into it and found this question on stackoverflow, but that is mainly about a space within the file paths.

I did find a bug posted about this issue in a specific version of scp, but I'm not sure how to patch scp on OSX. The patch is offered as a .c file.

My last resort is to create a new username on the Windows 7 box and transfer all my profile settings to that new user. It seems like a real hassle given that I can login via ssh, but not scp.

Any tips?

like image 245
ariestav Avatar asked Feb 24 '12 04:02

ariestav


People also ask

How do you SCP a file with a space in the name?

3. Escape Spaces with Both Backslash and Quotation in Scp. The third method of escaping spaces in path names is by combining backslash and quotation marks. This is especially important when copying files from a remote computer.

Can I SCP to a Windows machine?

»Windows doesn't support SSH/SCP/SFTP natively. « Neither does Linux or any other OS.


1 Answers

Add a special configuration to your Mac user's ssh config, usually in ~/.ssh/config

Host mySpaceyUsernameHost
User "Some User"
HostName WindowsHost

You should then be able to scp your file using that named configuration:

scp myfile mySpaceyUsernameHost:~/myfile

I just tried this on OS X 10.7 (Lion) and it worked from one Mac to another, whereas the other options (quoted, or backlash-escaped) did not.... so that's something.

like image 54
bpanulla Avatar answered Oct 06 '22 01:10

bpanulla