From 25f5cf04ea8d1d72295d09769da22ab1e1bc5d8d Mon Sep 17 00:00:00 2001 From: woodmeal <104011197+woodmeal@users.noreply.github.com> Date: Fri, 22 Apr 2022 09:50:35 +0200 Subject: [PATCH] Adding env handlement for ssh profile sessions (#6242) --- tabby-ssh/src/session/ssh.ts | 8 ++++++++ tabby-ssh/tsconfig.typings.json | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tabby-ssh/src/session/ssh.ts b/tabby-ssh/src/session/ssh.ts index f0da8f13..5174a0d1 100644 --- a/tabby-ssh/src/session/ssh.ts +++ b/tabby-ssh/src/session/ssh.ts @@ -306,6 +306,14 @@ export class SSHSession { this.authUsername = 'root' } } + if (this.authUsername?.startsWith('$')) { + try { + const result = process.env[this.authUsername.slice(1)] + this.authUsername = result ?? this.authUsername + } catch { + this.authUsername = 'root' + } + } ssh.connect({ host: this.profile.options.host.trim(), diff --git a/tabby-ssh/tsconfig.typings.json b/tabby-ssh/tsconfig.typings.json index 891a0f24..5446e796 100644 --- a/tabby-ssh/tsconfig.typings.json +++ b/tabby-ssh/tsconfig.typings.json @@ -10,6 +10,7 @@ "paths": { "tabby-*": ["../../tabby-*"], "*": ["../../app/node_modules/*"] - } + }, + "types": ["node"] } }