go - 尝试使用 goftp 库上传文件会出现 "502 RFC 2228 authentication not implemented."错误

标签 go ftp

我正在尝试使用 FTP(使用 goftp 库)将文件上传到服务器。这是我当前的代码:

package main

import (
    "crypto/tls"
    "github.com/dutchcoders/goftp"
    "fmt"
    "strings"
    "path/filepath"
    "os"
)

var client *goftp.FTP

func main() {
    // connect to FTP
    client, err := goftp.ConnectDbg("192.168.206.226:21")
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
    defer client.Close()

    config := tls.Config{
        InsecureSkipVerify: true,
        ClientAuth:         tls.RequestClientCert,
    }

    if err = client.AuthTLS(&config); err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    if err := client.Login("aaa", "bbbb"); err != nil {
        fmt.Println(err)
        os.Exit(1)
    }

    // upload new S10 file using FTP
    err = filepath.Walk("c:\\Temp", upload)
    if err != nil {
        fmt.Println(err)
        os.Exit(1)
    }
}

func upload(path string, f os.FileInfo, err error) error {
    if strings.Compare(f.Name(), "S10") == 0 {
        path := strings.TrimSuffix(path, f.Name())

        var file *os.File
        if file, err = os.Open(path); err != nil {
            fmt.Println(err)
            os.Exit(1)
        }

        defer file.Close()
        if err := client.Stor("/sd1/myFile", file); err != nil {
            fmt.Println(err)
            os.Exit(1)
        }
    }

    return nil
}

我遵循了 goftp 上可用的代码github 页面,但它对我不起作用。我总是收到此错误:

go : 2018/05/09 10:23:28 < 220 192.168.206.226 FTP server (QNXNTO-ftpd 20081216) ready.
At line:1 char:1
+ go run main.go
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (2018/05/09 10:2...0081216) ready.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

2018/05/09 10:23:28 220 192.168.206.226 FTP server (QNXNTO-ftpd 20081216) ready.
2018/05/09 10:23:28 > AUTH TLS
502 RFC 2228 authentication not implemented.

2018/05/09 10:23:28 < 502 RFC 2228 authentication not implemented.
exit status 1

我做错了什么吗?似乎无法理解问题所在。

最佳答案

您的 FTP 服务器不支持 TLS/SSL 加密。所以你不能使用它。

删除 AuthTLS 调用。

关于go - 尝试使用 goftp 库上传文件会出现 "502 RFC 2228 authentication not implemented."错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50247865/

相关文章:

go - 用于显示 golang 在线 API 文档的 VS Code 键盘快捷键?

c# - 替代 .NET 的 Uri 实现?

python - 从 FTP 检索文件时如何指定本地目标文件夹

linux - 使用 SFTP 在基于 Windows 的服务器(主机)和 Linux 服务器(客户端)之间进行同步

sql - 迁移后,gorm关系不会出现在数据库中

Golang IPv6 服务器

go - 如何定义返回函数的函数?

php - file_put_contents() : connect() failed: Permission denied in AWS server

c# - 连接到 ftps ://URL