Using FtpClient to connect to the server getReplyCode () in java returns 530, but it is normal to connect using the SSH tool.

problem description

Using FtpClient to connect to the server getReplyCode () in

java returns 530, but it is normal to connect using the SSH tool.

the environmental background of the problems and what methods you have tried

you have a FTP server IP and account password in hand. The same account password can be logged in using the SSH tool (port: 22), but the FtpClient method of apache.commons.net.ftp.FTPClient is called in java. Port 21 is used. Through the information seen in the source code, the replyCode obtained from a login method that comes with FtpClient is 530. Using isPositiveCompletion () also returned false. Try to connect to another FTP server and get normal results. Here is the information returned by both telnet servers. (there is nothing wrong with the code, after all, it is the package method of apache.)

servers that FTPClient cannot log in are shown in the following figure :

FTPClient:

login(user_list,ftpuser,vaftpd.conf)


related codes

/ / Please paste the code text below (do not replace the code with pictures)

    private static String hostname = "**.***.***.**";
    private static int port = 21;
    private static String username = "root";
    private static String pass = "rootroot";
    
    FTPClient ftpClient = new FTPClient();
    logger.debug("FTP-DETAILS-");
    ftpClient.connect(hostname, port);
    int reply = ftpClient.getReplyCode();
    if (!FTPReply.isPositiveCompletion(reply)) {
        ftpClient.disconnect();
    }
    // 
    boolean b = ftpClient.login("root", "rootroot");
    int test = ftpClient.getReplyCode(); //->530

what result do you expect? What is the error message actually seen?

    replyCode=530

Apr.28,2021

you can log in using ssh, which means that the server has ssh, enabled, but it does not mean that the target server has ftp service. It's normal that you can't log in. You should use client that supports ssh instead of FtpClient.


java is not good at it, give a strong answer

Ftp active mode and passive mode
prot and pasv
the difference between active mode and passive mode is as follows: active mode is the port through which the "server" connects to the "client", and passive mode is the port through which the "client" connects to the "server".
so you first need to determine which mode your FTP, uses, and then look at the FTPClient documentation and how it supports both modes

also, your not allowed also includes root,. Why are you still logging in with root in the code?


1. First of all, check whether the system has enabled the vsftp service, and if not, turn on the service first.

2. View configuration

configuration of vsftpd, vsftpd user connection control configuration is defined in the configuration file.
vsftpd.ftpusers: is located in the / etc/vsftpd directory. It specifies which user accounts cannot access the FTP server, such as root, and so on.
vsftpd.user_list: is located in the / etc/vsftpd directory. User accounts in this file also do not have access to the FTP server by default, only if the userlist_enable=NO option is enabled in the vsftpd .conf configuration file.
vsftpd.conf: is located in the / etc/vsftpd directory. Customize the configuration of FTP servers such as user login control, user rights control, timeout settings, server function options, server performance options, server response messages, and so on.

3. After the configuration modification is completed, execute service vsftpd restart to restart the vsftpd service.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3af46-2b7a0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3af46-2b7a0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?