Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
action: async (params, options) => {
const applicationOrDevice =
params.applicationOrDevice_raw || params.applicationOrDevice;
const bash = await import('bash');
// TODO: Make this typed
const hasbin = require('hasbin');
const { getSubShellCommand } = await import('../utils/helpers');
const { child_process } = await import('mz');
const {
exitIfNotLoggedIn,
exitWithExpectedError,
getOnlineTargetUuid,
} = await import('../utils/patterns');
const sdk = BalenaSdk.fromSharedOptions();
const verbose = options.verbose === true;
// ugh TODO: Fix this
const proxyConfig = (global as any).PROXY_CONFIG;
const useProxy = !!proxyConfig && !options.noProxy;
const port = options.port != null ? parseInt(options.port, 10) : undefined;
// if we're doing a direct SSH connection locally...
if (
validateDotLocalUrl(applicationOrDevice) ||
validateIPAddress(applicationOrDevice)
) {
const { performLocalDeviceSSH } = await import('../utils/device/ssh');
return await performLocalDeviceSSH({
address: applicationOrDevice,
port,
import { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import * as globalTunnel from 'global-tunnel-ng';
import * as _ from 'lodash';
import * as net from 'net';
import * as sdk from 'balena-sdk';
import * as ssh2 from 'ssh2';
import * as stream from 'stream';
import { getDeviceContainerInfo } from '../utils/containers';
import { normalizeUuidProp } from '../utils/normalization';
import * as patterns from '../utils/patterns';
import { hostOSAccess } from './command-options';
const balena = sdk.fromSharedOptions();
export const ssh: CommandDefinition<
{ uuid?: string },
{ host?: boolean; noproxy?: boolean }
> = {
signature: 'ssh [uuid]',
description: '(beta) get a shell into the running app container of a device',
help: stripIndent`
Use this command to get a shell into the running application container of
your device.
Examples:
$ balena ssh MyApp
$ balena ssh 7cf02a6
$ balena ssh 7cf02a6 -s`,