imba97 / picgo-plugin-sftp-uploader

picgo插件 SFTP 上传
MIT License
22 stars 2 forks source link

上传失败 #6

Closed 276562578 closed 2 years ago

276562578 commented 2 years ago

通过ssh -i xxx username@host 登陆成功,但上传出现如下情况,一直卡进度条

2022-06-27 18:34:36 [PicGo INFO] Before transform 
2022-06-27 18:34:36 [PicGo INFO] Transforming... Current transformer is [path] 
2022-06-27 18:34:36 [PicGo ERROR] process error begin
------Error Stack Begin------
TypeError: Error processing argument at index 0, conversion failure from 
    at Object.callback (D:\software\install place\picgo\resources\app.asar\background.js:2:572024)
    at Object.create (D:\software\install place\picgo\resources\app.asar\background.js:2:572546)
    at D:\software\install place\picgo\resources\app.asar\background.js:2:575011
    at Array.map (<anonymous>)
    at Object.handle (D:\software\install place\picgo\resources\app.asar\background.js:2:574900)
    at D:\software\install place\picgo\resources\app.asar\node_modules\picgo\dist\index.cjs.js:1:15722
    at Array.map (<anonymous>)
    at xe.handlePlugins (D:\software\install place\picgo\resources\app.asar\node_modules\picgo\dist\index.cjs.js:1:15656)
    at xe.beforeUpload (D:\software\install place\picgo\resources\app.asar\node_modules\picgo\dist\index.cjs.js:1:14745)
    at xe.start (D:\software\install place\picgo\resources\app.asar\node_modules\picgo\dist\index.cjs.js:1:13858)
-------Error Stack End-------
2022-06-27 18:34:36 [PicGo ERROR] process error end
2022-06-27 18:34:36 [PicGo INFO] Before upload 
2022-06-27 18:34:36 [PicGo INFO] beforeUploadPlugins: renameFn running 
2022-06-27 18:34:37 [PicGo INFO] Uploading... Current uploader is [sftp-uploader] 
2022-06-27 18:34:37 [PicGo ERROR] process error begin
------Error Stack Begin------
Error: All configured authentication methods failed
    at doNextAuth (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\client.js:803:21)
    at tryNextAuth (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\client.js:993:7)
    at USERAUTH_FAILURE (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\client.js:373:11)
    at 51 (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\protocol\handlers.misc.js:337:16)
    at Protocol.onPayload (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\protocol\Protocol.js:2025:10)
    at AESGCMDecipherNative.decrypt (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\protocol\crypto.js:987:26)
    at Protocol.parsePacket [as _parse] (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\protocol\Protocol.js:1994:25)
    at Protocol.parse (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\protocol\Protocol.js:293:16)
    at Socket.<anonymous> (C:\Users\watcherman\AppData\Roaming\picgo\node_modules\ssh2\lib\client.js:713:21)
    at Socket.emit (node:events:394:28)
-------Error Stack End-------
2022-06-27 18:34:37 [PicGo ERROR] process error end
imba97 commented 2 years ago

SSH 报错 All configured authentication methods failed,感觉还是没登录上 参考一下:《sftp连接服务器报All configured authentication methods failed》

276562578 commented 2 years ago

SSH 报错 All configured authentication methods failed,感觉还是没登录上 参考一下:《sftp连接服务器报All configured authentication methods failed》

我使用的是非root账户,以及key认证,sshd_config关闭了密码登陆,仅允许key,然后我手动-i key的文件和配置里的文件是同一个,但没提示key错误,反而提示这个,就很奇怪

imba97 commented 2 years ago

emmm 那就奇怪了,root 可以上传成功吗

276562578 commented 2 years ago

没试过root,我权限都配置好了的,手动touch没问题

276562578 commented 2 years ago

刚试了下root,一样的报错

276562578 commented 2 years ago

我尝试了密码登陆,是可以上传成功的,同样服务器允许密码的前提下,使用key登陆不成功,但这个key文件我都用了好久了,肯定没问题, 猜测是由于解析key文件的代码有一些未考虑的情况,比如我这个key文件只有私钥,大概是这个原因?

imba97 commented 2 years ago

配置文件是怎么写的

276562578 commented 2 years ago
{
    "domain": {
      "url": "https://domain.com",
      "path": "/pic/{fullName}",
      "uploadPath": "/var/www/html/pic/{fullName}",
      "host": "domain.com",
      "port": 22,
      "username": "username",
      "privateKey": "C:/Users/username/.ssh/key",
      "dirMode": "0755"
    }
  }
imba97 commented 2 years ago

好像没啥问题,正常用 ssh 命令能登录目标服务器吗

276562578 commented 2 years ago

好像没啥问题,正常用 ssh 命令能登录目标服务器吗

可以的,我猜测是key文件,我的key文件只包含私钥,您的插件解析那部分可能解析的是带公钥和私钥的key文件,或者您加更多的log,我再尝试下

276562578 commented 2 years ago
-----BEGIN RSA PRIVATE KEY-----
123
-----END RSA PRIVATE KEY-----

这是我的key文件的内容

imba97 commented 2 years ago

有可能吧,这个插件底层是用了 ssh2,这个包不支持这种的话应该就不行的

276562578 commented 2 years ago

读了这个ssh2,发现问题出在我的密钥是RSA的,生成ED25519就好了