奇怪的问题在这里. 运行通过ssh抛出调用rsync的脚本 “Permission denied (publickey). rsync: connection unexpectedly closed (0 bytes received so far) [receiver]” 奇怪的是: ssh user @ host工作正常,所以ssh键都设
运行通过ssh抛出调用rsync的脚本
“Permission denied (publickey). rsync: connection unexpectedly closed
(0 bytes received so far) [receiver]”
奇怪的是:
> ssh user @ host工作正常,所以ssh键都设置正确
>将脚本生成的命令记录并粘贴到终端中
>从脚本运行whoami显示正确的用户,并通过process.env将环境传递给spawn实例
>从脚本运行ssh user @ host不会抛出错误并返回缓冲区,因此这似乎有效
>运行脚本(只是执行已经测试过的命令)会引发上述错误
var spawn = require('child_process').spawn; spawn('rsync', [ '-avc', '--delete', '"'+src+'"' , '--link-dest="'+path.join(dest, folder_name)+'"', '"'+path.join(dest, 'latest/')+'"' ],{ cwd: process.cwd(), env: process.env });尝试指定密钥的路径
rsync -avz -e "ssh -i /home/thisuser/cron/thishost-rsync-key" remoteuser@remotehost:/remote/dir /this/dir/