Grunt Sftp Deployment using ppk file
Add Grunt sftp-deploy plugin using below command
npm install grunt-sftp-deploy
Create the Gruntfile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
grunt.initConfig({ | |
//server deployment | |
'sftp-deploy': { | |
build: { | |
auth: { | |
host: 'wwww.hostname.com', | |
port: 22, | |
authKey: 'privateKeyCustom' | |
}, | |
cache: 'sftpCache.json', | |
src: "js_files/", | |
dest: "/var/www/root2", | |
serverSep: '/', | |
concurrency: 4, | |
progress: true | |
} | |
}, | |
}); | |
grunt.loadNpmTasks('grunt-sftp-deploy'); | |
}; |
Create the .ftppass The below file will contains the server connection details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"privateKeyCustom": { | |
"username": "root", | |
"keyLocation": "E:/credentials/keys/serverkey.ppk" | |
} | |
} |
With any luck, you will get a sweet deployment result like this after enter the below command
$ grunt sftp-deploy:build
>> Logging in with key at E:/credentials/keys/serverkey.ppk
>> Concurrency : 4
transferred=[1/3] elapsed=[0.0s] overall=[33%] eta=[0.0s] [====== ]
>> Directories done.
transferred=[2/3] elapsed=[0.7s] overall=[67%] eta=[0.4s] [============ ]
>> Transferred : 0 Mb
Done, without errors.
>> Logging in with key at E:/credentials/keys/serverkey.ppk
>> Concurrency : 4
transferred=[1/3] elapsed=[0.0s] overall=[33%] eta=[0.0s] [====== ]
>> Directories done.
transferred=[2/3] elapsed=[0.7s] overall=[67%] eta=[0.4s] [============ ]
>> Transferred : 0 Mb
Done, without errors.