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!
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
* Fix docs generation when building on windows #729 [Tim Perry]

View File

@ -808,6 +808,7 @@ Examples:
$ resin ssh 7cf02a6
$ resin ssh 7cf02a6 --port 8080
$ resin ssh 7cf02a6 -v
$ resin ssh 7cf02a6 -s
### Options
@ -819,6 +820,10 @@ ssh gateway port
increase verbosity
#### --host, -s
access host OS (for devices with Resin OS >= 2.7.5)
#### --noproxy
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'
boolean: true
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.
###
{ hostOSAccess } = require('../command-options')
_ = require('lodash')
localHostOSAccessOption = _.cloneDeep(hostOSAccess)
localHostOSAccessOption.description = 'get a shell into the host OS'
module.exports =
signature: 'local ssh [deviceIp]'
description: 'Get a shell into a resinOS device'
@ -43,11 +49,7 @@ module.exports =
description: 'increase verbosity'
alias: 'v'
,
signature: 'host'
boolean: true
description: 'get a shell into the host OS'
alias: 's'
,
localHostOSAccessOption,
signature: 'container'
parameter: 'container'
default: null

View File

@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
###
commandOptions = require('./command-options')
module.exports =
signature: 'ssh [uuid]'
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 --port 8080
$ resin ssh 7cf02a6 -v
$ resin ssh 7cf02a6 -s
'''
permission: 'user'
primary: true
@ -44,7 +47,7 @@ module.exports =
boolean: true
description: 'increase verbosity'
alias: 'v'
,
commandOptions.hostOSAccess,
signature: 'noproxy'
boolean: true
description: "don't use the proxy configuration for this connection.
@ -109,7 +112,7 @@ module.exports =
username: resin.auth.whoami()
uuid: device.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')
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?
Promise.try ->
sshProxyCommand = getSshProxyCommand(hasTunnelBin)
if options.host
accessCommand = "host #{uuid}"
else
accessCommand = "enter #{uuid} #{containerId}"
command = "ssh #{verbose} -t \
-o LogLevel=ERROR \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
#{sshProxyCommand} \
-p #{options.port} #{username}@ssh.#{proxyUrl} enter #{uuid} #{containerId}"
-p #{options.port} #{username}@ssh.#{proxyUrl} #{accessCommand}"
subShellCommand = getSubShellCommand(command)
child_process.spawn subShellCommand.program, subShellCommand.args,

View File

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