使curl使用密码auth而不是公钥认证

时间:2015-12-02 18:00:01

标签: curl sftp

我使用curl --insecure --user user1:password1 -T test.txt sftp://company1.com/incoming/ -vvv将文件发送到SFTP。

在输出中我看到

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying xxx.xxx.xxx.xxx...
  0     0    0     0    0     0      0      0 --:--:--  0:00:02 --:--:--     0* Connected to transfer.dotz.com.br (xxx.xxx.xxx.xxx) port 22 (#0)
  0     0    0     0    0     0      0      0 --:--:--  0:00:03 --:--:--     0* SSH MD5 fingerprint: 1954076a7e4299f00df823fa1ca2d30e
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0* SSH authentication methods available: password,publickey
* Using SSH public key file '(nil)'
* Using SSH private key file '/home/ec2-user/.ssh/id_rsa'
* SSH public key authentication failed: Username/PublicKey combination invalid
* Failure connecting to agent
* Authentication failure
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0
* Closing connection 0
curl: (67) Authentication failure

当我明确指出--user参数时,我不明白为什么它抱怨“SSH公钥验证失败”。显然我的密码没有使用......

你可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

为什么不使用直接sftp命令?它也尝试按键,但是以一种相当的方式让你甚至不知道它。

这样做是因为ssh的默认行为是使用默认位置的键(参见sshd_config(5)的手册页)。

您可以采取一些措施来避免这种情况:

  • 从默认位置移除密钥以删除警告
  • 尝试修改您的客户端配置以禁用pubkey身份验证:PubkeyAuthentication no中的~/.ssh/config(可能不会受到尊重)
  • 使用/etc/sshd_config中的相同选项在服务器上禁用pubkey身份验证并重新启动服务器(但这通常不是您想要执行的操作)。

但无论如何,从另一个问题来看,solution更好:

curl -v --insecure sftp://user1:password1@company1.com
相关问题