How to regularly send file from Windows to Linux server - linux

I have a simple question. I want my Windows 7 PC to send a file to Linux server every minute. This would be easy to do on Linux via cronjobs but I have really no idea how to do that on Windows.
For example. We have a file called example.txt in c:/programfiles/folder/ on my Windows PC.
I want to send that file to Linux server to folder /home/fold.
Any idea what to use and how? Does Windows have anything similar to
cronjob? What to use instead of scp? Maybe use FTP but my Linux server
only works with explicit TLS and I have no idea how to force ftp
client to send that file in Windows.
Ty in advance and sorry if I ask stupid question.

Windows equivalent to the cron is Windows Task Scheduler.
The Windows ftp.exe client does not support TLS/SSL. It also does not support a passive FTP mode. So you have to use a different client. Once you have to use a different client anyway, you can use SFTP.
So take any scriptable SFTP client (or FTPS or SCP client if your prefer) and schedule it to be run using Windows Scheduler.
For example with WinSCP, you can use a batch-file like:
#echo off
winscp.com /log=winscp.log /command ^
"open sftp://user:password#example.com/" ^
"put c:\path\file.txt /path/" ^
"exit"
(WinSCP supports FTPS and SCP too).
Then, in Windows control panel go to System and Security > Administrative Tools > Schedule Tasks and add a new task.
For details see my guide for scheduling file transfers to FTP/SFTP server.
(I'm the author of WinSCP)

Related

alternative for net use in Linux

I am currently working on file transferring system from one server to another one in Linux. I'm still a novice coder and new with Linux. I found that in Window we can actually use net use to connect a server to another server something like:
net use destination_server/user:username password
Is there a way, we can apply the same concept in linux?
Would really appreciate the help, Thanks.
You may use ssh but remote server should have ssh server installed.
example command :
ssh username#destination_server
Other alternatives :
sftp : You may transfer files but it won't provide direct shell access to remote server meaning you can not use all commands available in that server.
scp : one line command to transfer files and folders.

"421 Active data channel timed out." with FTP client connection from Azure VM from SQL stored procedure

We're migrating from a Windows server box to Virtual Machines on Azure. Our SQL stored procedure uses Integration Services packages to generate feed files and upload them to client ftp servers.
We do this by building script files and using the native ftp.exe client on Windows. My script file looks like this:
open ftp.ourserver.net
myusername
mypassword123
lcd G:\
cd /
prompt
put "G:\DataFeeds\SmithCo_02272017.txt" "SmithCo_DailyFeed.txt"
bye
This works fine on our old server. When I use command prompt to run this code I'm getting:
421 Active data channel timed out.
I can upload the file manually with just a basic connection using WinSCP client on that machine.
I thought it was a port issue so I created an outbound rule in Windows Firewall for port 21, allowed all connection.
Then I created an endpoint in Azure for port 21 as well.
Is there another step to open this up or something I may be missing?
The Windows command-line ftp.exe supports the FTP active mode only. In the active mode, the server has to connect back to the client to establish data connection for a file transfer. More over the ftp.exe does not allow you to pick, what port is used for the data connection. It randomly picks any available port number above 1024. So you would have to create end points for all ports above 1024. That's possibly something you do not want to do. Though you can try.
WinSCP works, because it (as most modern FTP clients) uses the passive mode by default. For the passive mode, you do not need to open any ports on the client side.
Read my article about network configuration for FTP active and passive connection modes for details.
As WinSCP works for you, you can use WinSCP scripting interface to replace your ftp.exe script.
It would be like (ftp.txt):
open ftp://myusername:mypassword123#ftp.ourserver.net/
lcd G:\
cd /
put "G:\DataFeeds\SmithCo_02272017.txt" "SmithCo_DailyFeed.txt"
exit
(Though the lcd is redundant, both in your and WinSCP script).
And run the script like:
winscp.com /script=ftp.txt
See the guide to converting Windows FTP script to WinSCP script.
(I'm the author of WinSCP)

Is it possible to set up a GitLab Linux server and work off Windows PCs?

I'm looking at setting up a gitlab server (using a linux machine) with several devs on Windows PCs using it. I basically wanted to know if that's possible? I can't seem to find a definitive answer!
Thanks!
Yes, it's definitely possible. I'm using just the same - GitLab hosted on a Linux server while devs are on both Windows and Linux (VMs running on Windows).
Techically, there's no difference to it. You use SSH and HTTPS for client-server communication which are standard platform independent protocols. It's the same as using github.com, gitlab.com or any other such provider from any operating system.
The place I work has Gitlabs deployed can be on a linux server, while developers can be on either Windows or Linux desktops.
Git makes use of SSH and to connect to remote clients and Windows doesn't support SSH out of the box, however the installer for git comes bundled with all the features you will need to run a shell and connect to a remote server via SSH on windows. It also includes a basic UI, Git-Gui. You can download the installer from http://git-scm.com.

How to copy files on remote Windows to local Linux on a Linux machine?

Currently, I'm working on a local Linux machine. I'm trying to use scp or similar Linux command-line tools to copy files from a remote Windows machine to my local Linux. I did some searching and found that most of the solutions are for local Windows cases (like putty and winscp), which don't really help.
Please advise.Thank you.
[UPDATE] Solved by installing cygwin's sshd service on Windows.
If you really want to use SCP, you will need an SCP server (actually an SSH server) on the Windows machine.
For example freeSSHd.
You will need to choose one of the options based on your own needs, there are a number of similar tools and freeSSHd was the first in the list on Google. I've used the Bitvise SSH Server in the past but it is only free for non-commercial use.
They are usually very easy to set up. You install them the usual way and run them for the first time. Depending on the tool, they may pick up your existing Windows users or you may need to manually create some users with passwords within the tool. Then, armed with your PC's IP address, you should be able to connect to the PC using SSH from the Linux command line.
If the windows system has a shared folder you should be able access that with smbclient which is part of the terrific samba project.
Usually somthing like:
smbclient //winmachine/share
Possibly using the -U username options to specifiy the username on the windows box.
Once connected, you can use cd to change folders, and get to retrieve files.
If there is no file share.... I dunno. Create one?
Syntax for copying from remote Windows 10 machine with built-in SSH server. Note forward slashes and drive style. Domain is not necessary.
scp user#domain#example.com:c:/path/to/file.txt .

Remote commands execution and file acces in Linux and Windows

Suppose I have a server application installed in a few Linux and Windows machines. Now I would like to control it remotely. That is, I would like to start and stop the application, update the application configuration files, reads the logs remotely.
It looks to be easy in the Linux worlds. I can use ssh, scp, and probably nfs to execute commands in remote Linux machines and access files there. The problem is that I would like to execute commands and access files in remote Linux and Windows machines uniformly from a Windows machine. I need also some scripting capabilities too.
What is the best way to do that?
You can try to use cygwin http://www.cygwin.com/ on your windows machines and install a ssh server with it.
If you need graphical tools, use VNC
there is an OpenSS implementation targeting Windows at http://sshwindows.sourceforge.net/download/
since there is (besides Cygwin/MinGW) no possibility to run bash code (ksh/csh/tcsh code as well) you should make yourself familiar with the windows scripting host.

Resources