1

I can transfer file from linux to linux. Also can transfer from linux to windows or windows to linux by using cmd pscp command. But system asks for password. So I have tried winscp batch command for skipping password.

Now I want to transfer file from linux to windows share folder on daily basis like cronjob. The action will be executed in linux system. Because client only give me windows share folder links.

Hosain Ahmed
  • 11
  • 1
  • 3
  • 1
    Is there any reason you cannot use the OpenSSH server now available in Windows? And public-key authentication? – Hermann Aug 26 '19 at 18:02
  • It was client requirements. So I have only share destination folder. But I can do anything to source linux server. – Hosain Ahmed Aug 26 '19 at 18:22
  • Can you clarify your question. Do you speak of "client" as in "customer" or "client and server"? You tagged the question with SFTP yet you seem to ask for a solution without SSH specifically. – Hermann Aug 26 '19 at 18:33

1 Answers1

1

The Samba project has created several tools that let you access Windows shares from a Linux machine; two options to automatically upload the file are:

  • Mount the Windows share somewhere (using the kernel CIFS filesystem). You'd use mount -t cifs -o credentials=/path/to/credfile,uid=some-local-uid //server/share /mnt/whatever (there are options for setting the username/password, or using credential files, and for setting who can access the share; see the mount.cifs manpage). And of course, like any other mounted filesystem, you can put it in /etc/fstab. Then you can upload the file using, e.g., cp.

  • use the smbclient command-line program, which is a similar idea to sftp (or ftp). Command would be something like: smbclient -A /path/to/credfile -c "put local-filename" //server/share

Please note, especially if sending over the Internet, that Windows shares in many configurations offer much weaker/nonexistent encryption and authentication than SSH.

derobert
  • 109,670
  • Thinks for your reply. I asked to client for windows ftp server but they gave me open shared folder on private network. I have preferred 2nd option. Can I save this command in shell .sh file and set a task on cronjob? – Hosain Ahmed Aug 26 '19 at 18:03
  • @HosainAhmed yes, you can put that in a shell script and run it as a cronjob. You can do that with basically every command. – derobert Aug 26 '19 at 18:40