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

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)

Related

Far Manager NetBox SFTP can't connect to the linux server

I'm trying to connect to the RedHat Linux server through Far Manager 3.0.5800.0 x64 and NetBox plugin with SFTP. But it doesn't open the session as I expect it and doesn't exposure any errors. The connection screen blinks once and disappears, get me back to the NetBox: Stored sessions panel.
I CAN connect to that server through putty ssh, and it seems to be completely ok.
I CAN connect through Far Manager to THAT server as a different user also as a root user.
The problem was that I recently wrote in the .bashrc file some strings with "echo" command. And it seems to be after that the NetBox doesn't want to establish a session by that user.
So just inspect your .bashrc file and clean all echo commands.

Remote SSH/SFTP with Netbeans

I know you can set up remote connection in Netbeans or as others have suggested, mount the remote file system locally and let Netbeans read that.
This current set-up I have to SSH into a remote server and then SSH again into another one.
Is it possible in Netbeans to access the filesystem on the 2nd server hop?
I think you can setup a SSH local port forwarding on your first remote server to archive what you want here. Once ssh connection established with the first server, it will be tunnel to second server. Also, will be much more convenient if using SSH public key as authentication method.
Run below command on your local (Need to keep this running)
ssh -NL 2222:server2.example.com:22 server1.example.com
Test connection with ssh locally
ssh localhost 2222
So in your case, Netbeans just need to connect to localhost port 2222.
Ref: https://www.ssh.com/ssh/tunneling/example
That isn't answer you expect, but to big to put it in comment.
I think best solution is configure autostart some service which will create tunnel to first server on your login and bind local port (let's say 2222) to second remote server ssh port. This is basical feature of ssh client. When you can configure Netbeans to connect to localhost:2222 and login right into second server. You might need to use keys authentication for first server.
Where are examples to make such thing. Like is underneath link on article
http://www.pc-freak.net/blog/start-ssh-tunnel-pc-boots-windows-alwaysup/
Since you can get ssh access via a daisy-chain, you can very likely use SSHFS:
https://github.com/libfuse/sshfs
Available in Debian (and therefore, likely many other distributions):
https://packages.debian.org/jessie/sshfs
As long as you have ssh keys set up properly on each server, you can daisy-chain mounting via SSHFS to the machine where your NetBeans app is running.
https://en.wikipedia.org/wiki/SSHFS
NOTE: There are some caveats, including that SSHFS expects that it is the only mechanism used to update the filesystem, and that there is only one writer at a time. Undesirable behavior can occur if you allow other mechanisms to change the files or directories on the target server, including data loss and/or corruption.

How to regularly send file from Windows to Linux server

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)

How do you set up a perforce server to work over the internet?

I was setting up a Perforce server and only noticed options for localhosts and such. What I'm trying to do is setup up the server on a desktop machine at one household, and then be able to connect to it using the P4V Client to access the files over the internet form a another household. I no that I'll have to forward some ports and stuff but what set up files do I need to do this? I can only find info for servers that are all being run on the same network like at a business or something nothing that is over the internet. I've set up a team speak server like this where you go to connect and type in the ip address and port and then connect to the server but this dosn't have options like that, that I've seen anyway. This will be done all on Windows 7 64 bit machines. Server on desktop and clients will be on desktops and laptops. All help is appreciated and I'll be posting back with updates on what i'm doing so others can follow this as well if needed.
The server accepts TCP/IP connections, which can be from any client machine which has TCP/IP connectivity. The Perforce server configuration for telling it which IP address and port number to listen at is the P4PORT setting: http://www.perforce.com/perforce/r12.2/manuals/cmdref/env.P4PORT.html
Since you're on a Windows machine, your server will probably be run as a Windows Service, and hence its P4PORT setting will be held in the registry section for that service. You can edit the service's configuration using a registry editor such as RegEdit, or more simply you can use 'p4 set -S Perforce P4PORT=my-host-name:my-port-number' to specify the desired IP address and port.
Then restart your Perforce service from the Services Control Panel and you're good to go!

Active FTP Mode not Working in Linux

I am new to Linux and I have my application running on windows for a while and for file Transfer stuff we use third party sftp and it has been running well both on Active and Passive mode.
Now i am migrating my app to support Linux OS, and i'm facing problem in FTP Active mode, where i can transfer files in Passive mode.
I tried through FTP command where i can transfer files in both mode and when it comes implementations it gives me the following error:
500 Invalid PORT Command.
and the before this error the ftp command looks like :
PORT 0,0,0,0,234,96
where for passive it works fine.
Do it need to enable any firewall settings in linux, Please help me out.
PORT 0,0,0,0,234,96
The first four octets represent the IP address, which in this case, seems like is absent. So you either missed out declaring the client's IP address in the application or may be there is some other issue with the IP addresses. Try this link for more info: FTP
Also check if its getting connected when you turn off the Linux firewall.
/etc/init.d/iptables stop

Resources