Gruntjs 无法获取grunt scp、grunt sftp、grunt------除了grunt ftp之外,任何要上载到我的服务器的内容

Gruntjs 无法获取grunt scp、grunt sftp、grunt------除了grunt ftp之外,任何要上载到我的服务器的内容,gruntjs,grunt-ssh,Gruntjs,Grunt Ssh,所以,我正在努力让grunt scp工作。我在一家大型电信公司工作,我是他们系统的内部人员,或者在家里使用VPN。我可以使用ssh连接到服务器并使用WINSCP 下面是我的例子: 现在我的代码是: 先决条件: .ftppass or secret.json. Either will work //WIN SCP scp: { qat2: { options: { host: '123.45.678.900',

所以,我正在努力让grunt scp工作。我在一家大型电信公司工作,我是他们系统的内部人员,或者在家里使用VPN。我可以使用ssh连接到服务器并使用WINSCP

下面是我的例子:

现在我的代码是:

先决条件:

.ftppass or secret.json. Either will work

//WIN SCP
    scp: {
        qat2: {
            options: {
                host: '123.45.678.900',
                port: 443,
                username: '<%= secret.qat2.username %>',
                password: '<%= secret.qat2.password %>'
            },
            files: [{
                    cwd: allFiles.srcPath.client,
                    src: '**/*',
                    //filter: 'isDirectory',
                    dest: allFiles.uploadServer + '**/*'
                }]
        }
    },
allFiles.uploadServer=与上述相同,但适用于服务器

loadNpmTasks

grunt.loadNpmTasks('grunt-scp');
现在,grunt注册任务:

//SCP
grunt.registerTask('scpThis', [
    'scp:qat2',
    'clean:qat2'
], function () {
    try {
        grunt.task.run([
            'scp:qat2',
            'clean:qat2'
        ]);
    }
    catch (e) {
        console.log("SCP Connection failed...", e);
    }
    console.log("pkg: ", pkg);
    console.log("Starting SCP SEQUENCE");
});
清理被召回清理远程服务器,我有一个本地当我

以下是该部分:

 clean: {
        build: {
            src: [ //THIS IS FOR LOCAL Build
                '**/*.*',
                '/docs/*.*'
                        //,
                        //Uncomment out to use
                        //allFiles.destPath.server + '*.*'
            ]
        },
        qat2: { //Thus is for the server when it's called above
            options: {
                force: true
            },
            src: allFiles.uploadServer + '**/*'

        }
    },
结果如下:

Starting SCP SEQUENCE

//JUST SO EVERYONE KNOWS: The server IPs are FAKE and the question in the
//comments below seems like PVG50 thinks they are REAL.  Ah, they are not.
//in any case, IF THEY were real and then the REAL IPs do connect and then
//close. Thoughts on this please?

11:54:59 - Running "scp:qat2" (scp) task
11:54:59 - ssh connect 123.45.678.90
11:54:59 - ssh close 123.45.678.90
11:54:59 - 
Running "clean:qat2" (clean) task //This didn't clean the server since the connection closed...
>> 0 paths cleaned.

Done, without errors.

Execution Time (2015-12-13 19:54:57 UTC)
11:54:59 - loading tasks   1.5s  ████████████████████████████████████ 77%
scp:qat2       441ms  ███████████ 22%
Total 2s
这不管用

以下是我对sftp的尝试:

//SFTP - SSH EXEC
    sftp: {
        deploy: {
            command: "sudo su",
            auth: {
                host: '<%= secret.qat2.ip %>',
                port: 443,
                authKey: 'key1'
            },
            files: {
                src: allFiles.destPath.client
            },
            options: {
                path: allFiles.uploadServer,
                directoryPermissions: parseInt(777, 8),
                createDirectories: true
            }
        }
    },

//SFTP DEPLOY
    'sftp-deploy': {
        build: {//SERVERS GO HERE LIKE BELOW
            command: "sudo su",
            auth: {
                host: '<%= secret.qat2.ip %>',
                port: 443,
                authKey: 'key1'
            },
            cache: 'sftpCache.json', //OMIT from Source Control Stores Locally
            expand: true,
            src: [
                allFiles.destPath.client + 'images/{,*/}*.*',
                allFiles.destPath.client + 'images/*.jpg',
                allFiles.destPath.client + 'images/*.png',
                allFiles.destPath.client + 'scripts/config/*.json',
                allFiles.destPath.client + 'tmpl/*.js',
                allFiles.destPath.client + '*.html',
                allFiles.destPath.client + 'views/*.html',
                allFiles.destPath.client + 'views/**/*.html',
                allFiles.destPath.client + 'favicon.ico',
                allFiles.destPath.client + '.htaccess'
            ],
            dest: allFiles.uploadServer,
            concurrency: 4,
            progress: true
        }
    },
我已经使用grunt两年了,这一次让我很为难

我想做的是:

  • 连接到服务器
  • 清理部署目录
  • 将已编译的应用程序从我的计算机推送到服务器
  • 运行我的脚本,无论哪个都可以
  • 接收没有错误但实际有效的通知
  • 使用WINSCP在服务器上验证文件是否确实存在(这可以正常工作-我是说查看目录)

  • 感谢所有人提供的帮助

    ,此服务器可能实际运行在端口443上?是的,还有其他端口。您有解决方案吗?发生的情况是,它正在连接,然后关闭:11:54:59-运行“scp:qat2”(scp)任务11:54:59-ssh connect 123.45.678.90 11:54:59-ssh close 123.45.678.90-如何“保持”它打开?没有,但您可以在远程端日志中检查是否尝试了连接或查找报告的错误。似乎远端刚刚关闭了你的连接。您也可以在本地或远程vm中运行ssh服务器,尝试使用基本的gruntscp示例并对其进行修改,直到它们看起来更像您要做的。这也使您能够在两个endsPVG上进行调试和诊断。谢谢,我有一个shell的SSH连接点。让我试试,我会给你回复的,我很抱歉上面的评论,先生。非常感谢。
    //SFTP - SSH EXEC
        sftp: {
            deploy: {
                command: "sudo su",
                auth: {
                    host: '<%= secret.qat2.ip %>',
                    port: 443,
                    authKey: 'key1'
                },
                files: {
                    src: allFiles.destPath.client
                },
                options: {
                    path: allFiles.uploadServer,
                    directoryPermissions: parseInt(777, 8),
                    createDirectories: true
                }
            }
        },
    
    //SFTP DEPLOY
        'sftp-deploy': {
            build: {//SERVERS GO HERE LIKE BELOW
                command: "sudo su",
                auth: {
                    host: '<%= secret.qat2.ip %>',
                    port: 443,
                    authKey: 'key1'
                },
                cache: 'sftpCache.json', //OMIT from Source Control Stores Locally
                expand: true,
                src: [
                    allFiles.destPath.client + 'images/{,*/}*.*',
                    allFiles.destPath.client + 'images/*.jpg',
                    allFiles.destPath.client + 'images/*.png',
                    allFiles.destPath.client + 'scripts/config/*.json',
                    allFiles.destPath.client + 'tmpl/*.js',
                    allFiles.destPath.client + '*.html',
                    allFiles.destPath.client + 'views/*.html',
                    allFiles.destPath.client + 'views/**/*.html',
                    allFiles.destPath.client + 'favicon.ico',
                    allFiles.destPath.client + '.htaccess'
                ],
                dest: allFiles.uploadServer,
                concurrency: 4,
                progress: true
            }
        },
    
    23:21:59 - Running "sftpDeployThis" task
    23:21:59 - Starting SFTP SERVER DEPLOYMENT SEQUENCE
    23:21:59 - Running "sftp-deploy:build" (sftp-deploy) task
    23:21:59 - Warning: /var/www/html/app/oauth2/v1/images/{,*/}*.* is not an existing location Use --force to continue.
    23:21:59 - 
    Aborted due to warnings.
    23:21:59 - 
    
    Execution Time (2015-12-13 07:21:58 UTC)
    23:21:59 - loading tasks      1.4s  ███████████████████████████████████████████ 99%
    sftp-deploy:build  15ms  █ 1%
    Total 1.4s