picgo-plugin-sftp-uploader
picgo-plugin-sftp-uploader copied to clipboard
建议增加对非root用户的支持
这个插件很不错,可是我在上传的时候出现了错误,我初步分析了认为是权限问题, 因为我使用了非root用户。
ssh 远程登陆一般都不是root, 但是很多非root用户可以用 sudo免密进行scp 等操作。
所以我建议增加非root用户的支持, 类似于ansible里有个参数 become:yes, 不知道是否可行。
谢谢。
不过我用了以下办法也不行啊,还是提示无权限, 尽管我认为解决了权限问题
先
mkdir /home/myname/picgo
sudo ln -s /home/myname/picgo /xxx/xxx/wp-content/uploads/picgo/
sudo chown myname:www-data -R /xxx/xxx/wp-content/uploads/picgo/
然后
{
"Wordpress": {
"url": "https://mydomain.com",
"path": "/wp-content/uploads/picgo/{year}/{month}/{fullName}",
"uploadPath": "/home/myname/picgo/{year}/{month}/{fullName}",
"host": "m.y.i.p",
"port": 22,
"username": "myname",
"privateKey": "C:/Users/myname/.ssh/id_rsa",
"fileUser": "www-data:www-data",
"dirMode": "0755"
}
}
贴一下错误日志, 似乎路径有问题,但是我看不出来
2022-05-12 16:08:01 [PicGo INFO] [PicGo Server] is listening at 36677
2022-05-12 16:08:16 [PicGo INFO] Before transform
2022-05-12 16:08:16 [PicGo INFO] Transforming... Current transformer is [path]
2022-05-12 16:08:16 [PicGo INFO] Before upload
2022-05-12 16:08:16 [PicGo INFO] beforeUploadPlugins: renameFn running
2022-05-12 16:08:16 [PicGo INFO] Uploading... Current uploader is [sftp-uploader]
2022-05-12 16:08:16 [PicGo ERROR] SFTP 发生错误,请检查用户名、私钥和密码是否正确
2022-05-12 16:08:16 [PicGo ERROR]
------Error Stack Begin------
TypeError: Cannot read property 'path' of undefined
at Object.exports.formatPath (C:\Users\myname\AppData\Roaming\picgo\node_modules\picgo-plugin-sftp-uploader\dist\util.js:35:26)
at Object.upload [as default] (C:\Users\myname\AppData\Roaming\picgo\node_modules\picgo-plugin-sftp-uploader\dist\upload.js:24:29)
at async Object.handle (C:\Users\myname\AppData\Roaming\picgo\node_modules\picgo-plugin-sftp-uploader\dist\index.js:23:13)
at async Lifecycle.doUpload (D:\Scoop\apps\picgo\2.3.0\resources\app.asar\node_modules\picgo\dist\src\core\Lifecycle.js:80:9)
at async Lifecycle.start (D:\Scoop\apps\picgo\2.3.0\resources\app.asar\node_modules\picgo\dist\src\core\Lifecycle.js:26:13)
at async PicGo.upload (D:\Scoop\apps\picgo\2.3.0\resources\app.asar\node_modules\picgo\dist\src\core\PicGo.js:205:32)
at async Object.upload (D:\Scoop\apps\picgo\2.3.0\resources\app.asar\background.js:36:29196)
at async Pt (D:\Scoop\apps\picgo\2.3.0\resources\app.asar\background.js:36:31625)
-------Error Stack End-------
2022-05-12 16:08:16 [PicGo SUCCESS]
出问题的是大概是以下语句
path: userConfig.path,
uploadPath: userConfig.uploadPath
补充下 sftp myname@myhost 用密钥登陆是成功的, ls 命令下 也能正确看到 /home/myname/picgo的目录, 而且 mkdir 也能产生目录