记一次ftp服务器下载文件 530 问题

记一次ftp服务器下载文件 530 问题

阿里云搭建 FTP 服务器

第一步

// 安装vsftpd
yum install -y vsftpd

第二步

修改vsftpd配置文件

进入安装的vsftpd目录下:
[root@iZbp1f2xn3w6b7ozws0bg7Z ~]# cd /etc/vsftpd/
[root@iZbp1f2xn3w6b7ozws0bg7Z vsftpd]# ls
ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

vsftpd.conf 核心配置文件
user_list 用户列表 允此文件里的用户允许访问 FTP 服务器
ftpusers 黑名单 此文件里的用户不允许访问 FTP 服务器

修改配置文件
1、anonymous_enable = YES 改为 anonymous_enable = NO
2、注释掉user_list 文件和 ftpusers 文件中的 root 并保存

# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
#root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

第三步

重启ftp服务

// 查询ftp服务状态
service vsftpd status

// 重启服务命令
systemctl restart vsftpd.service

// 启动服务命令
systemctl start vsftpd.service

第四步

阿里云服务器设置安全组可入端口
在这里插入图片描述

第五步

测试是否能连接ftp服务器,当出现 230 Login successful. 证明设置成功!

C:\Users\Administrator>ftp 56.91.122.15
连接到 56.91.122.15220 (vsFTPd 3.0.2)
200 Always in UTF8 mode.
用户(47.97.121.25:(none)): root
331 Please specify the password.
密码:
230 Login successful.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
可以使用 Apache Commons Net 库来实现FTP文件下载。以下是一个简单的示例代码,仅供参考: ```java import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class FTPDownloadExample { public static void main(String[] args) { String server = "ftp.example.com"; int port = 21; String user = "username"; String password = "password"; String remoteFilePath = "/path/to/file.txt"; String localFilePath = "/path/to/save/file.txt"; FTPClient ftpClient = new FTPClient(); try { ftpClient.connect(server, port); ftpClient.login(user, password); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); OutputStream outputStream = new FileOutputStream(localFilePath); boolean success = ftpClient.retrieveFile(remoteFilePath, outputStream); outputStream.close(); if (success) { System.out.println("File downloaded successfully."); } else { System.out.println("Failed to download file."); } } catch (IOException e) { e.printStackTrace(); } finally { try { if (ftpClient.isConnected()) { ftpClient.logout(); ftpClient.disconnect(); } } catch (IOException e) { e.printStackTrace(); } } } } ``` 在本示例中,我们使用 `FTPClient` 连接到FTP服务器,登录并进入被动模式。然后,我们将文件类型设置为二进制,从远程FTP服务器下载文件,将其保存到本地文件系统上,最后关闭连接。请注意,如果文件下载成功,`retrieveFile` 方法将返回 `true`,否则返回 `false`。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值