0

I use curl --insecure --user user1:password1 -T test.txt sftp://company1.com/incoming/ -vvv to send my file to SFTP.

In the output I see

  % 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

I don't understand why it complains on "SSH public key authentication failed" while I explicitly indicated --user argument. Apparently my password is not used...

Could you help?

snowindy
  • 3,117
  • 9
  • 40
  • 54

1 Answers1

1

Why don't you use direct sftp command? It also tries the keys, but in a quite way so you don't even know it.

It does this because it is default behaviour of ssh to use keys that are in default location (see manual page for sshd_config(5)).

There are few things that you can do to avoid this:

  • Remove the key from default location to remove the warning
  • Try to modify your client config to disable pubkey authentication: PubkeyAuthentication no in ~/.ssh/config (it might not be honoured)
  • Disable pubkey authentication on server with the same option in /etc/sshd_config and restart server (but this is usually not what you want to do).

But anyway, here is better solution from another question:

curl -v --insecure sftp://user1:password1@company1.com
Community
  • 1
  • 1
Jakuje
  • 24,773
  • 12
  • 69
  • 75