Scenario
550
errors when connecting to an FTPS
client in implicit
mode using apache commons FTPSClient
library.
Solution
Set execPROT:
execPBSZ(0)
execPROT("P")
Example to connect and upload a file:
import org.apache.commons.net.ftp.FTPSClient
new FTPSClient("TLSv1", true).with {
connect "localhost", 990
execPBSZ(0)
execPROT("P")
login "user", "pass"
setControlEncoding("UTF-8");
enterLocalPassiveMode()
setFileType(FTP.ASCII_FILE_TYPE)
setFileTransferMode(FTP.ASCII_FILE_TYPE)
changeWorkingDirectory ("/home/user")
def stream = new BufferedInputStream(
new FileInputStream("file.txt"))
if (stream.available() == 0) {
throw new Exception("Cannot read local file stream!")
}
result = it.storeFile(destFilename, stream)
stream.close()
logout()
disconnect()
}
Note: Connecting with lftp
:
You'll need data-protection as well:
lftp -e "set ftp:ssl-protect-data true; put -O / /file/to/upload.txt; bye” -u user user,pass ftp://ftp.host.com