Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Support verbose flag for remote shell ssh command
Browse files Browse the repository at this point in the history
  • Loading branch information
lekkas committed Jun 22, 2016
1 parent 870a966 commit 9d497cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 3 additions & 2 deletions build/ssh.js
Expand Up @@ -45,7 +45,7 @@ utils = require('./utils');
*/

exports.getConnectCommand = function(options) {
var containerId, port, result, username, uuid;
var containerId, port, result, username, uuid, verbose;
if (options == null) {
options = {};
}
Expand Down Expand Up @@ -92,6 +92,7 @@ exports.getConnectCommand = function(options) {
}
});
username = options.username, uuid = options.uuid, containerId = options.containerId, port = options.port;
result = "ssh -p " + port + " -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null " + username + "@ssh." + (settings.get('proxyUrl')) + " rsync " + uuid + " " + containerId;
verbose = options.verbose ? '-vv ' : '';
result = "ssh " + verbose + "-p " + port + " -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null " + username + "@ssh." + (settings.get('proxyUrl')) + " rsync " + uuid + " " + containerId;
return result;
};
12 changes: 11 additions & 1 deletion lib/ssh.coffee
Expand Up @@ -75,6 +75,16 @@ exports.getConnectCommand = (options = {}) ->

{ username, uuid, containerId, port } = options

result = "ssh -p #{port} -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null #{username}@ssh.#{settings.get('proxyUrl')} rsync #{uuid} #{containerId}"
verbose = if options.verbose then '-vv ' else ''
result = """
ssh \
#{verbose}\
-p #{port} \
-o LogLevel=ERROR \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
#{username}@ssh.#{settings.get('proxyUrl')} \
rsync #{uuid} #{containerId}
"""

return result
3 changes: 2 additions & 1 deletion tests/ssh.spec.coffee
Expand Up @@ -19,5 +19,6 @@ describe 'SSH:', ->
uuid: '1234'
containerId: '4567'
port: 8080
verbose: true

m.chai.expect(command).to.equal('ssh -p 8080 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null test@ssh.resindevice.io rsync 1234 4567')
m.chai.expect(command).to.equal('ssh -vv -p 8080 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null test@ssh.resindevice.io rsync 1234 4567')

0 comments on commit 9d497cf

Please sign in to comment.