copy file from windows to Linux
Use Samba.
Samba provides a file sharing service compatible with Windows.
You can share a directory (for example /srv/samba/sharename
) on your Linux computer and access it from Windows like this: \\linuxservername\sharename
. It doesn't need any extra software on the Windows side.
Samba is included in most Linux distributions. Install it using the package manager, for example:
Ubuntu:
sudo apt-get install samba smbclient
SUSE:
zypper samba
CentOS/RedHat:
yum install samba
To configure Samba, see:
Ubuntu: http://ubuntuforums.org/showthread.php?t=202605
SUSE: http://doc.opensuse.org/documentation/html/openSUSE/opensuse-reference/cha.samba.html
CentOS/RedHat: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-samba-configuring.html
or search Google to find a guide for your distribution.
Note that you may need to configure your Linux firewall, in case you use one, to accept connections to ports 137/tcp, 138/tcp, 139/tcp and 445/tcp (see this and this).
In the description above the Linux computer is a Samba server and Windows mounts a share from it.
In your comment below you mention that you'd like to automate the transfer process. This can be achieved by reversing the roles so that Windows acts as the server and Linux connects to it using smbclient
.
With smbclient
you don't need to mount the Windows share at all. For example, to retrieve C:\Directory\file.txt
and copy it to /tmp
on your Linux computer do this:
smbclient '//windowsserver/c$' -c 'lcd /tmp; cd Directory; get file.txt' -U administrator%password
-c
Command to execute. See man smbclient
for details.
-U
Username and password for accessing the share specified as username%password
Modify it to your needs and add it to your script.
I know you said you can't expect specific software to be installed, but there are SSH/SCP/SFTP clients for Windows which do not require any particular installation; only the executable being available. One that I keep turning to is PuTTY with its companion pscp
and psftp
tools, but I am certain that alternatives exist. pscp
and psftp
can be driven completely from the command line, and thus are well-suited for automation tasks. Both of them even have a -batch
switch which is described as "disable all interactive prompts" and almost certainly can be leveraged.
Since you presumably already have a SSH/SCP/SFTP server installed and configured on the server, this avoids having to install any software on either host just for the purpose of copying those files.
Another upside might be the fact that PuTTY is open source under a permissive license, so if it doesn't do what you want straight out of the box, it should be relatively easy to make it act the way you prefer.