无法使用 ftp 传输文件 - 权限被拒绝

无法使用 ftp 传输文件 - 权限被拒绝

我正在使用 Ubuntu,我想要一个脚本,每天将我的 mysql 数据库从我的本地硬盘传输到我的 ftp 服务器(提供商是 Aruba)。

当我使用 Filezilla 时,我可以正确地通过 FTP 连接并传输文件,但是当我使用 ftp 时遇到问题。

这是我的脚本:

#!/bin/sh
mysqldump -u root isola > bdd-13-11-2019.sql
ftp -n > ftp_$$.log <<EOF
 verbose
 open ftp.robo-dyne.com 
 user [email protected]
 my_password
 put bdd-13-11-2019.sql
 bye
EOF

我总是收到这个错误:

Verbose mode on.
Connected to ftp.robo-dyne.com.
220-#
220-#                                 
220-#  Aruba.it                    
220-#  The Web Hosting Company     
220-#                                 
220-#
220 This is a private system - No anonymous login
331 User [email protected] OK. Password required
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
local: bdd-13-11-2019.sql remote: bdd-13-11-2019.sql
200 PORT command successful
553 Can't open that file: Permission denied
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.

我不需要严格使用 ftp,我可以使用任何其他解决方案。我已经尝试使用 curl,但没有成功。

编辑:文件的权限是:

isola@isola-virtual-machine:~/Documents/Isola02$ whoami
isola
isola@isola-virtual-machine:~/Documents/Isola02$ ls -la | grep bdd
-rw-rw-rw- 1 isola isola 1619317 nov 13 22:18 bdd-13-11-2019.sql

EDIT2:它在终端上也不起作用:

ftp> open ftp.robo-dyne.com
Connected to ftp.robo-dyne.com.
220-#
220-#                                 
220-#  Aruba.it                    
220-#  The Web Hosting Company     
220-#                                 
220-#
220 This is a private system - No anonymous login
Name (ftp.robo-dyne.com:isola): [email protected]
331 User [email protected] OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> put ftp_22584.log 
local: ftp_22584.log remote: ftp_22584.log
200 PORT command successful
553 Can't open that file: Permission denied
ftp> bye
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.

答案1

我发表我的评论作为答案是为了帮助其他有同样问题的用户。

我通过考虑以下几点来解决这个问题:

  1. 主文件夹不可写,所以我需要cd到子文件夹
  2. 使用PASV模式
  3. 使用binary模式传输文件

答案2

一个线索——filezilla 经常以 root 特权 (sp?) 模式运行。如果您将其设置为以这种方式运行,并且传输有效,我会自己使用 filezilla。那么文件的权限就无关紧要了。我不知道如何编写脚本,经常使用 filezilla。

也许您可以尝试使用 sudo 以 root 身份进行 ftp?再次查看脚本,尝试使用 isola 的管理员 ID 登录服务器。

好的,您现在正在连接到 FTP 服务器吗?那么您无法匿名登录。您需要使用在 FTP 服务器上具有 root 权限的 ID 登录服务器。

相关内容