Auto-merge for PR #737 via VersionBot

Add ssh option for direct host OS access
This commit is contained in:
resin-io-versionbot[bot] 2017-12-19 08:45:56 +00:00 committed by GitHub
commit 743392017d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 9 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/). This project adheres to [Semantic Versioning](http://semver.org/).
## v6.12.0 - 2017-12-19
* Add ssh option for direct host OS access #737 [Andreas Fitzek]
## v6.11.0 - 2017-12-18 ## v6.11.0 - 2017-12-18
* Fix docs generation when building on windows #729 [Tim Perry] * Fix docs generation when building on windows #729 [Tim Perry]

View File

@ -808,6 +808,7 @@ Examples:
$ resin ssh 7cf02a6 $ resin ssh 7cf02a6
$ resin ssh 7cf02a6 --port 8080 $ resin ssh 7cf02a6 --port 8080
$ resin ssh 7cf02a6 -v $ resin ssh 7cf02a6 -v
$ resin ssh 7cf02a6 -s
### Options ### Options
@ -819,6 +820,10 @@ ssh gateway port
increase verbosity increase verbosity
#### --host, -s
access host OS (for devices with Resin OS >= 2.7.5)
#### --noproxy #### --noproxy
don't use the proxy configuration for this connection. Only makes sense if you've configured proxy globally. don't use the proxy configuration for this connection. Only makes sense if you've configured proxy globally.

View File

@ -98,3 +98,9 @@ exports.advancedConfig =
description: 'show advanced configuration options' description: 'show advanced configuration options'
boolean: true boolean: true
alias: 'v' alias: 'v'
exports.hostOSAccess =
signature: 'host'
boolean: true
description: 'access host OS (for devices with Resin OS >= 2.7.5)'
alias: 's'

View File

@ -14,6 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
### ###
{ hostOSAccess } = require('../command-options')
_ = require('lodash')
localHostOSAccessOption = _.cloneDeep(hostOSAccess)
localHostOSAccessOption.description = 'get a shell into the host OS'
module.exports = module.exports =
signature: 'local ssh [deviceIp]' signature: 'local ssh [deviceIp]'
description: 'Get a shell into a resinOS device' description: 'Get a shell into a resinOS device'
@ -43,11 +49,7 @@ module.exports =
description: 'increase verbosity' description: 'increase verbosity'
alias: 'v' alias: 'v'
, ,
signature: 'host' localHostOSAccessOption,
boolean: true
description: 'get a shell into the host OS'
alias: 's'
,
signature: 'container' signature: 'container'
parameter: 'container' parameter: 'container'
default: null default: null

View File

@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
### ###
commandOptions = require('./command-options')
module.exports = module.exports =
signature: 'ssh [uuid]' signature: 'ssh [uuid]'
description: '(beta) get a shell into the running app container of a device' description: '(beta) get a shell into the running app container of a device'
@ -31,6 +33,7 @@ module.exports =
$ resin ssh 7cf02a6 $ resin ssh 7cf02a6
$ resin ssh 7cf02a6 --port 8080 $ resin ssh 7cf02a6 --port 8080
$ resin ssh 7cf02a6 -v $ resin ssh 7cf02a6 -v
$ resin ssh 7cf02a6 -s
''' '''
permission: 'user' permission: 'user'
primary: true primary: true
@ -44,7 +47,7 @@ module.exports =
boolean: true boolean: true
description: 'increase verbosity' description: 'increase verbosity'
alias: 'v' alias: 'v'
, commandOptions.hostOSAccess,
signature: 'noproxy' signature: 'noproxy'
boolean: true boolean: true
description: "don't use the proxy configuration for this connection. description: "don't use the proxy configuration for this connection.
@ -109,7 +112,7 @@ module.exports =
username: resin.auth.whoami() username: resin.auth.whoami()
uuid: device.uuid uuid: device.uuid
# get full uuid # get full uuid
containerId: resin.models.device.getApplicationInfo(device.uuid).get('containerId') containerId: if options.host then '' else resin.models.device.getApplicationInfo(device.uuid).get('containerId')
proxyUrl: resin.settings.get('proxyUrl') proxyUrl: resin.settings.get('proxyUrl')
hasTunnelBin: if useProxy then hasbin('proxytunnel') else null hasTunnelBin: if useProxy then hasbin('proxytunnel') else null
@ -117,12 +120,18 @@ module.exports =
throw new Error('Did not find running application container') if not containerId? throw new Error('Did not find running application container') if not containerId?
Promise.try -> Promise.try ->
sshProxyCommand = getSshProxyCommand(hasTunnelBin) sshProxyCommand = getSshProxyCommand(hasTunnelBin)
if options.host
accessCommand = "host #{uuid}"
else
accessCommand = "enter #{uuid} #{containerId}"
command = "ssh #{verbose} -t \ command = "ssh #{verbose} -t \
-o LogLevel=ERROR \ -o LogLevel=ERROR \
-o StrictHostKeyChecking=no \ -o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \ -o UserKnownHostsFile=/dev/null \
#{sshProxyCommand} \ #{sshProxyCommand} \
-p #{options.port} #{username}@ssh.#{proxyUrl} enter #{uuid} #{containerId}" -p #{options.port} #{username}@ssh.#{proxyUrl} #{accessCommand}"
subShellCommand = getSubShellCommand(command) subShellCommand = getSubShellCommand(command)
child_process.spawn subShellCommand.program, subShellCommand.args, child_process.spawn subShellCommand.program, subShellCommand.args,

View File

@ -1,6 +1,6 @@
{ {
"name": "resin-cli", "name": "resin-cli",
"version": "6.11.0", "version": "6.12.0",
"description": "The official resin.io CLI tool", "description": "The official resin.io CLI tool",
"main": "./build/actions/index.js", "main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli", "homepage": "https://github.com/resin-io/resin-cli",