diff --git a/src/server/command/ssh.ts b/src/server/command/ssh.ts index 09c70d7..c1b24c2 100644 --- a/src/server/command/ssh.ts +++ b/src/server/command/ssh.ts @@ -2,17 +2,26 @@ import isUndefined from 'lodash/isUndefined.js'; import { logger } from '../../shared/logger.js'; export function sshOptions( - { pass, path, command, host, port, auth, knownHosts, config }: Record, + { + pass, + path, + command, + host, + port, + auth, + knownHosts, + config, + }: Record, key?: string, ): string[] { const cmd = parseCommand(command, path); const hostChecking = knownHosts !== '/dev/null' ? 'yes' : 'no'; - const sshRemoteOptsBase = [ - 'ssh', - host, - '-t', - config !== '' ? '-F' : '', - config, + logger.info(`Authentication Type: ${auth}`); + let sshRemoteOptsBase = ['ssh', host, '-t']; + if (config !== '') { + sshRemoteOptsBase = sshRemoteOptsBase.concat(['-F', config]); + } + sshRemoteOptsBase = sshRemoteOptsBase.concat([ '-p', port, '-o', @@ -21,8 +30,7 @@ export function sshOptions( `UserKnownHostsFile=${knownHosts}`, '-o', `StrictHostKeyChecking=${hostChecking}`, - ]; - logger.info(`Authentication Type: ${auth}`); + ]); if (!isUndefined(key)) { return sshRemoteOptsBase.concat(['-i', key, cmd]); }