Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit 1109588

Browse files
author
Eddie Flores
committed
Merge pull request #5 from keown/master
add more options to ssh configuration
2 parents 70480ee + a6fd77d commit 1109588

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var stagingEnvironment = {
2626
type: 'ssh', // the default store is 'redis', use 'ssh' for this addon.
2727
remoteDir: process.env['APP_STAGING_REMOTE_DIR_PATH'],
2828
host: process.env['APP_STAGING_REMOTE_HOST_IP'],
29+
port: process.env['APP_STAGING_REMOTE_SSH_PORT'],
2930
username: process.env['APP_STAGING_REMOTE_USERNAME'],
3031
privateKeyFile: process.env['APP_STAGING_REMOTE_PRIVATE_KEY']
3132
},
@@ -46,6 +47,18 @@ module.exports = {
4647

4748
```
4849

50+
**SSH Configuration**
51+
52+
The following parameters are available to setup correctly ssh:
53+
54+
* **host** - Hostname or IP address of the server (**required**)
55+
* **username** - Username for authentication (**required**)
56+
* **port** - Port of the server (**optional**)
57+
* **privateKeyFile** - String that contains a private key for either key-based or hostbased user authentication (**optional**)
58+
* **passphrase** - Passphrase used to decrypt private key, if needed (**optional**)
59+
* **agent** - Path to ssh-agent's UNIX socket for ssh-agent-based user authentication (**optional**)
60+
61+
4962
## Directory Structure ##
5063

5164
The following directory structure is created on your server. The basic gist is that your revisions will be stored inside of their own directory along with meta data about the revision (date of commit, commit message, author of the commit, and commit hash). Information about your revisions is viewable via the following command `ember deploy:list -e <your environment>`.
@@ -104,4 +117,4 @@ $ ember deploy:activate -e staging -r <revisionId>
104117
```
105118

106119

107-
> This project is based on this repo: https://github.com/treyhunner/ember-deploy-ssh-index. Though, it's been heavily modified to serve a different purpose -credit where credit is due.
120+
> This project is based on this repo: https://github.com/treyhunner/ember-deploy-ssh-index. Though, it's been heavily modified to serve a different purpose -credit where credit is due.

lib/ssh-adapter.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ var noop = function () {};
1313
*/
1414
var connect = function (conn, config, cb) {
1515

16+
var ssh_config = {
17+
host: config.host,
18+
username: config.username,
19+
port: config.port || '22',
20+
agent: config.agent,
21+
passphrase: config.passphrase
22+
}
23+
24+
if (typeof config.privateKeyFile != 'undefined')
25+
ssh_config['privateKey'] = require('fs').readFileSync(config.privateKeyFile);
26+
1627
conn.on('ready', function () {
1728
cb();
1829
});
@@ -21,11 +32,7 @@ var connect = function (conn, config, cb) {
2132
cb(error);
2233
});
2334

24-
conn.connect({
25-
host: config.host,
26-
username: config.username,
27-
privateKey: require('fs').readFileSync(config.privateKeyFile),
28-
});
35+
conn.connect(ssh_config);
2936
};
3037

3138
/**
@@ -247,9 +254,16 @@ var upload = function (indexBuffer) {
247254
conn = _this.conn,
248255
config = _this.config,
249256
revisionDir = path.join(config.remoteDir, shortCommitId),
250-
host = config.host,
251-
username = config.username;
257+
ssh_config = {
258+
host: _this.config.host,
259+
username: _this.config.username,
260+
port: _this.config.port || '22',
261+
agent: _this.config.agent,
262+
passphrase: _this.config.passphrase
263+
};
252264

265+
if (typeof _this.config.privateKeyFile != 'undefined')
266+
ssh_config['privateKey'] = require('fs').readFileSync(_this.config.privateKeyFile);
253267

254268
conn.on('ready', function () {
255269
console.log('+- Connected.');
@@ -273,11 +287,7 @@ var upload = function (indexBuffer) {
273287

274288
conn.on('error', reject);
275289

276-
conn.connect({
277-
host: host,
278-
username: username,
279-
privateKey: require('fs').readFileSync(config.privateKeyFile)
280-
});
290+
conn.connect(ssh_config);
281291

282292
});
283293
};

0 commit comments

Comments
 (0)