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?
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.
»Windows doesn't support SSH/SCP/SFTP natively. « Neither does Linux or any other OS.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With