Answer the question
In order to leave comments, you need to log in
How can you do without passwords for git, ssh under Gulp?
DD. I’ll say in advance that maybe I chose the wrong tool, but for now I want to get by with what we already use.
I did the following thing for deployment on Gulp:
'use strict';
var gulp = require('gulp'),
// ...
fs = require('fs'),
expandTilde = require('expand-tilde'),
GulpSSH = require('gulp-ssh'),
config = require('./gulp-config.json');
//...
// deploy
var gulpSSH = new GulpSSH({
ignoreErrors: false,
sshConfig: {
host: 'host',
port: 'port',
username: 'username',
privateKey: fs.readFileSync(expandTilde('~/.ssh/id_rsa')),
passphrase: config.ssh.passphrase
}
});
gulp.task('deploy', function () {
return gulpSSH
.shell([
// пробелы перед командами, чтоб в историю не записывал на сервере
' cd /var/www/webiste',
' git pull https://' + config.git.username + ':' + config.git.password + '@bitbucket.org/username/project.git',
' composer install --prefer-dist --no-scripts --quiet',
' composer dump-autoload --optimize --no-dev --quiet',
// ' php yii migrate', // todo: test!
' npm install',
' npm run prod'
], {filePath: 'deploy.log'})
.pipe(gulp.dest('./gulp'))
});
{
"ssh": {
"passphrase": "Пароль от ssh ключа"
},
"git": {
"username": "Логин битбакета",
"password": "Пароль битбакета"
}
}
Answer the question
In order to leave comments, you need to log in
It is better to set up ssh agent forwarding to the server. A space before the command does little to no security. Anyone who has access to the server under the same user will be able to sniff all the commands that are entered. Git will pick up the agent itself if you fire via sshgit pull [email protected]/username/project.git
sshConfig: {
host: 'host',
port: 'port',
username: 'username',
agent: process.env.SSH_AUTH_SOCK,
agentForward: true
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question