Windows – How to transfer files from UNIX to Windows

file-transferscpunixwindows

I want to transfer a file from a UNIX server to a Windows 2003 Server, so I downloaded copssh onto the Windows server, and openssh is already installed on the UNIX server.

When I execute the following command (on the UNIX server):

scp -r /file_in_unix/ user@windows_hostname:\c:\\\

The following output appears (on the UNIX server's screen):

100% |***************************************************************|   562       00:00

However, When I go to see file in the C drive on the Windows server, I don't find anything. Why isn't the file showing up?

Best Answer

The destination path looks wrong - to most unix shells the backslash is an escape character not a path marker, so I'm guessing the file has dropped into the SSH user's home directory with an odd filename.

IIRC copssh is based on cygwin, so what you probably needed to run is:

scp -r /file_in_unix/ user@windows_hostname:/cygdrive/c/

An alternatives to copying to a SSH service on the Windows machine is to use a GUI client like WinSCP on the Windows box to login to the Unix machine and pull the files over that way - though this is not suitable if you are trying to automate the process.

If you have privileged access on the unix machine (i.e. you are, or can become via sudo or similar, root) and have the relevant support installed you could just copy the files onto a Windows share. You don't say what Unix you are using. For Ubuntu and similar checking that support is present and installing it if not can be done with sudo aptitude install smbfs, you can them mount a Windwos share with something like sudo mount -tcifs //11.22.33.44//sharename /mnt/tmp -ousername=WindowsUserName (where 11.22.33.44 is the IP address of the windows machine, depending on your network setup you may be able to refer to the machine by name rather than address). Once you've done that you can just use the basic file management tools (cp, mv, ...) to interact with that Windows share and call umount /mnt/tmp when you are done. You might want to choose a more meaningful mount point name than /mnt/tmp. You can leave the share mounted, of course, if the transfer of the data is to be automated/scheduled. This method does assume that the Unix machine can see the Windows machine's fileshares through any firewall arrangements that may exist between them.

Related Question