From ea33f10630e7ad45f889461b2a2aab2412a31a58 Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Tue, 19 Jan 2021 21:30:15 +0100 Subject: [PATCH] Allow configs to get properties from ssh_config files --- package.json | 12 +++++++++++- src/connect.ts | 14 ++++++++++++++ src/fileSystemConfig.ts | 2 ++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 688ebaa..19e121e 100644 --- a/package.json +++ b/package.json @@ -275,6 +275,16 @@ "items": "string", "default": [] }, + "sshfs.paths.ssh": { + "title": "A list of file locations to load ssh_config (OpenSSH) config files from", + "description": "Location of ssh_config files to load configs from", + "type": "array", + "items": "string", + "default": [ + "$HOME/.ssh/config", + "/etc/ssh/ssh_config" + ] + }, "sshfs.configs": { "title": "A list of SSH FS configurations", "description": "Use the Settings UI to edit configurations (run command SSH FS: Open settings and edit configurations)", @@ -345,4 +355,4 @@ "ssh2": "^0.8.9", "winreg": "^1.2.4" } -} +} \ No newline at end of file diff --git a/src/connect.ts b/src/connect.ts index fc624b1..7f6ad26 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -112,6 +112,20 @@ export async function calculateActualConfig(config: FileSystemConfig): Promise('paths.ssh'); + if (!paths) { + logging.debug('No value defined for sshfs.paths.ssh setting?'); + paths = []; + } + if (!paths.length) { + logging.error('Option \'sshConfig\' is set but the \'sshfs.paths.ssh\' setting has no paths'); + } + const { buildHolder, fillFileSystemConfig } = await import('./ssh-config'); + const holder = await buildHolder(paths); + await fillFileSystemConfig(config, holder); + } if (config.privateKeyPath) { try { const key = await toPromise(cb => readFile(config.privateKeyPath!, cb)); diff --git a/src/fileSystemConfig.ts b/src/fileSystemConfig.ts index 4ea92d6..75bbb8e 100644 --- a/src/fileSystemConfig.ts +++ b/src/fileSystemConfig.ts @@ -86,6 +86,8 @@ export interface FileSystemConfig extends ConnectConfig { root?: string; /** A name of a PuTTY session, or `true` to find the PuTTY session from the host address */ putty?: string | boolean; + /** Whether to parse ssh_config files (listed by the VS Code setting `sshfs.paths.ssh`) for extra parameters, e.g. Port */ + sshConfig?: boolean; /** Optional object defining a proxy to use */ proxy?: ProxyConfig; /** Optional path to a private keyfile to authenticate with */