2015-12-02 71 views
0

我使用curl --insecure --user user1:password1 -T test.txt sftp://company1.com/incoming/ -vvv將我的文件發送到SFTP。使curl使用密碼auth而不是公鑰認證

在輸出我看到

% 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 

我不明白爲什麼它抱怨的「SSH公鑰驗證失敗」,而我明確表示--user說法。顯然我的密碼沒有使用...

你能幫忙嗎?

回答

0

爲什麼不使用直接sftp命令?它也會嘗試按鍵,但是以相當的方式,所以你甚至不知道它。

這樣做是因爲它是ssh的默認行爲,使用默認位置的密鑰(請參閱手冊頁的sshd_config(5))。

有些事情很少,你可以做些什麼來避免這種情況:

  • 取下默認位置的鍵刪除警告
  • 嘗試修改客戶端配置文件中禁用PUBKEY認證:PubkeyAuthentication no~/.ssh/config(它可能不會被兌現)
  • 在服務器上使用/etc/sshd_config中的相同選項禁用pubkey身份驗證並重新啓動服務器(但這通常不是您想要的)。

但無論如何,這裏是另外一個問題更solution

curl -v --insecure sftp://user1:[email protected] 
+0

我試過,SFTP://用戶1:[email protected]失敗,同樣的結果 – snowindy

相關問題