Connect to a FTPS server within shell script - shell

I'm trying to connect to a FTPS (explicit TLS FTP) server within a shell script and i'm kinda confused.
I tried using the regular FTP command, but i get 534 error "policy requires SSL" and 504 "Security mechanism not implemented"
ftp -inuv myhost
Returns 504 then
quote USER myuser
Returns 534
I also tried sftp but i get "couldn't read packet: connection reset by peer".
That damn peer is making my life a nightmare since IRC ;)
sftp myuser#myhost:mydirectory/ -P21
Connexion reset by peer and it says it can't connect to port 22, which is weird since i specified port 21...
Thanks for your help

There is a diference between ftps and sftp : sftp is ftp over ssh, so in your case you cannot use sftp. ftps is ftp that use ssl/tls
You need an ftp client that manages TLS, for instance http://lftp.yar.ru/ (found on the net)

Related

Transfer Files through FTP in Windows Batch Scripts having Private Key

I am using these command to transfer a file to an SFTP location.It has an private key(Puttygen) with
passphrase.
open ftp://%1%:%2%#%3%/ -explicittls -certificate="32:4b:5e:a7:05:b9:e4:2d:7d:44:cb:c1:0e:ee:0e:17"-privatekey=D:\SSIS_DEV\DBTeam\Transfer\Rural\Private.ppk
put %4%
I am getting a timeout error while connecting.
exit
You want to use SFTP, but use FTP (ftp://) protocol in the session URL.
Use sftp:// instead:
open sftp://%1%:%2%#%3%/
FTP and SFTP are two completely different and incompatible protocols. You get the timeout, because you are trying to connect to the FTP port, which the server does not listen on.

ngrok FTP tunneling issue

I have installed many FTP Servers on a Windows machine and set ngrok for FTP tunneling.
C:\path\to\ngrok> ngrok tcp 21
Using linux, i am able to establish an FTP connection and browse the directories ONLY with the installed ftp client.
$ ftp
ftp> open 0.tcp.ngrok.io port_here
The problem is that FileZilla, Classic FTP File Transfer Software, Chrome & Firefox extensions, failed.
FileZilla output:
Command: LIST
Response: 150 Opening ASCII mode data connection
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
I wonder why i can't browse using FileZilla, but with the ftp Linux command works well.
Thank you.
Problem solved in FileZilla via :
Edit > Settings > Connection > FTP > Passive mode, and select "Fall back to active mode" and Bingo !
The same technique can be applied to the other FTP clients.

Unable to Retrieve Directory Using ProFTPD(WHM)

Well, after looking for many solutions. I came here now.
I am setting up WHM/cPanel for hosting website. Everything was going smooth but I am stuck on FTP connection (Server sent passive reply with unroutable address. Using server address instead.)
Server Details:
CentOS Linux release 7.2.1511 (Core)
WHM/cPanel Version 11.58.0.13
FTP Server: PureFTPD
Acutal error while connecting
To fix this issue and get FTP working you need to open up more numbered ports so FTP can connect. I assume you are using CSF.
Login to WHM then go to CSF >> Firewall Configuration >>
allow TCP_In 30000:50000 and TCP_Out 30000:50000
Once you made the changes Restart the firewall
Now you need to make changes in FTP config file to use these ports, you will find this file to this location /etc/pure-ftpd.conf
Now you will see a line as follows and you will need to uncomment it
# Port range for passive connections replies. - for firewalling.
PassivePortRange 30000 50000
Restart FTP Service and should work.

putty - psftp connection refused

Im trying to connect with PSFTP.exe but I got error, if I do the same in FTP in cmd line or Filezilla it works good. I have tried other ftps but nobody works.
C:\putty>psftp.exe ftp.mozilla.org
Fatal: Network error: Connection refused
Any suggestions? Do I need to start putty.exe or configure psftp in some way that I have missing?
Im working in Windows 7 64-bit
That's because PSFTP is not an FTP client, it's an SFTP client. Different protocols.

Ruby NET::FTP Not Resolving Correct IP

I am trying to connect to an FTP server using:
ftp = Net::FTPFXPTLS.new
ftp.passive=true
ftp.debug_mode=true
ftp.connect('200.111.111.11',21)
ftp.login('Username','Pass')
ftp.chdir('inbound')
ftp.putbinaryfile("./#{filename}", "/#{filename}")
ftp.close()
For the purposes of this example 200.111.111.11 is the correct IP and 10.1.1.1 is the fake IP.
When I connect via an FTP client such as Transmit I connect fine and everything works as normal but in the transcript it states:
Cmd: PASV
227: Entering Passive Mode (10,1,1,1,47,79).
Fixing bogus PASV data address from 10.1.1.1:12111 to 200.111.111.11:12111.
Then when it tries to connect via the ruby script:
get: 425 Failed to establish connection.
When it tries to do any action like LIST or STOR because the PASV command always returns 10.1.1.1:12111.
So is there anyway to ensure the PASV command uses 200.111.111.11 and not what is sent back to it?
This seems to be more of an issue with the gem, there is a solution for it but woud take a little while to implement. In order to save time we simply switched the protocol to use SFTP which works flawlessly. (Switched both server and code)

Resources