Transfer Files through FTP in Windows Batch Scripts having Private Key - windows

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.

Related

Ftp server in termux

How can I access termux files using ftp? I wants to write files using ftp, so i can use good editor for edit files.
My question is how can I set up my ftp server in termux?
You have to start ftp server in termux, for starting server you have to use tcpsvd for binding port.
tcpsvd -Ev localhost 8023 ftpd /sdcard
Now open ftp client or go to browser with ftp://localhost:8023
It will show all sdcard content, use more ftpd option to explore ftp.

How to upload the file to another SFTP server from shell channel by using Jsch?

Step 1: Session connect
....
session.connect()
Step 2: Shell channel
channel = session.openChannel("shell");
Step 3: Execute ssh commands to login Unix server and go to the required path cd /logs/server
PrintStream shellStream = new PrintStream(channel.getOutputStream()); // printStream for convenience
channel.connect();
shellStream.println(command);
shellStream.flush();
step 4: Get the file from Unix server and put into SFTP:
code to connect sftp channel and put the file from unix server to sftp.
So I want to upload the file (logs/server/server.log) from Unix server (which I logged in using shell channel) to SFTP server.
Both source and destination are remote.
Is it possible to do by using JSch?
An SFTP protocol (let alone JSch SFTP library) has no support for transfers between two remote servers.
If you have a shell access to one of the servers, you can try to transfer the files by using a command-line (OpenSSH) sftp client on the server. It's doable. Problematic is an authentication part, as it's non-interactive session. You would have to use an unencrypted private key, an agent forwarding or sshpass.
Obvious and simple implementation is to download the files from the "Unix" server to a local machine and then upload them to the "SFTP" server. But you need to use the SFTP channel, not the shell channel, for the download.

Downloading a file from FTP using kettle

I was trying to download a file form FTP server(Remote machine) using pentaho kettle (Get a file with FTP), I can able to do that in my local machine. But when i try to deploy the app in jboss web server it fails to download resulting in a error "Error getting files from FTP : Login incorrect."
But everything seems to be correct regarding the login details.
Did i have configure any where else in the server? Please help.
There are several things you could check in this case:
Check that the security settings of the remote FTP server allows for the machine that runs the job to establish an FTP connection. If you have access to the server, try the following command to ensure that the server has access:
telnet <your-remote-ftp-server-host> 21
# Or try:
telnet <your-remote-ftp-server-host> 22
Verify that the remote FTP server respects FTP connection requests, otherwise try SFTP (Get a file with FTP & Get a file with SFTP are two entirely different job steps in Kettle)
Wherever you are fetching your FTP credentials from (ideally a configuration file), test that the credentials are properly read by the job in the relevant scope - use the Write To Log step for that matter

Connect to a FTPS server within shell script

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)

How to upload a file from PC to AS400 machine using FTP Command

Need a Help about FTP command PUT.
Requirement is to upload a file from Windows PC to AS400 machine. Here is the command (running as a batch file) I am using:
open ipAddress
Kishore //user
pwd //password
quote RCMD CRTLIB LIB(TESTXA) TEXT('TESTXA Java Application Source') //Successfully creates TESTXA library
quote RCMD CRTSRCPF FILE(TESTXA/QJAVASRC) RCDLEN(200) TEXT('Java Source File') //Successfully creates source file QJAVASRC under TESTXA library
put "D:\Shared\JavaTest\ClobTest.java" /QSYS.LIB/TESTXA.LIB/QJAVASRC.FILE/CLOBTEST.MBR // Generating error 'ftp: bind : can't assign requested '
quote RCMD CHGPFM FILE(TESTXA/QJAVASRC) MBR(CLOBTEST) SRCTYPE(JAVA) TEXT('ClobTest') // Not executing due to previous command error
bye
Please suggest what am doing wrong with PUT command??
Thanks in advance
Smells like a firewall. Before doing the PUT, try setting passive mode. quote pasv
Specify namefmt 0 before put. Namefmt 0 tells ftp to use library/object naming.
Check the client proxy settings.
Bind: Can't Assign Requested Address from Ftp.exe Using Winsock Proxy
If the IP address of an external interface on the Proxy Server is in the LAT, it is considered by the proxy client to be internal. Because the client computer does not have an interface with the same IP address as the external IP address of the Proxy Server, you get the above error message.

Resources