Allow configs to get properties from ssh_config files

feature/ssh-config
Kelvin Schoofs 4 years ago
parent e5049e0163
commit ea33f10630

@ -275,6 +275,16 @@
"items": "string", "items": "string",
"default": [] "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": { "sshfs.configs": {
"title": "A list of SSH FS configurations", "title": "A list of SSH FS configurations",
"description": "Use the Settings UI to edit configurations (run command SSH FS: Open settings and edit 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", "ssh2": "^0.8.9",
"winreg": "^1.2.4" "winreg": "^1.2.4"
} }
} }

@ -112,6 +112,20 @@ export async function calculateActualConfig(config: FileSystemConfig): Promise<F
} }
logging.debug(`\tReading PuTTY configuration lead to the following configuration:\n${JSON.stringify(config, null, 4)}`); logging.debug(`\tReading PuTTY configuration lead to the following configuration:\n${JSON.stringify(config, null, 4)}`);
} }
if (config.sshConfig) {
await promptFields(config, 'host');
let paths = vscode.workspace.getConfiguration('sshfs').get<string[]>('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) { if (config.privateKeyPath) {
try { try {
const key = await toPromise<Buffer>(cb => readFile(config.privateKeyPath!, cb)); const key = await toPromise<Buffer>(cb => readFile(config.privateKeyPath!, cb));

@ -86,6 +86,8 @@ export interface FileSystemConfig extends ConnectConfig {
root?: string; root?: string;
/** A name of a PuTTY session, or `true` to find the PuTTY session from the host address */ /** A name of a PuTTY session, or `true` to find the PuTTY session from the host address */
putty?: string | boolean; 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 */ /** Optional object defining a proxy to use */
proxy?: ProxyConfig; proxy?: ProxyConfig;
/** Optional path to a private keyfile to authenticate with */ /** Optional path to a private keyfile to authenticate with */

Loading…
Cancel
Save